:root {
  --bg: #f6f5f2; --card: #fff; --text: #22252a; --muted: #6b7078; --line: #e2e0da;
  --accent: #2f6f6a; --accent-ink: #fff; --danger: #b3403a; --warn-bg: #fff4d6; --ok-bg: #e3f2ec; --err-bg: #fbe4e2;
  --s0: #2f6f6a; --s1: #c0623b;
  --radius: 10px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17191c; --card: #212429; --text: #e6e6e3; --muted: #9aa0a8; --line: #33373d;
    --accent: #5fb3aa; --accent-ink: #10201e; --danger: #e0756e; --warn-bg: #3a3320; --ok-bg: #1f3530; --err-bg: #3d2423;
    --s0: #5fb3aa; --s1: #e8916b;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); line-height: 1.5; }
a { color: var(--accent); }
h1 { font-size: 1.5rem; margin: .2em 0 .6em; }
h2 { font-size: 1.1rem; margin: 0 0 .6em; }

header.top { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1.5rem;
  padding: .7rem 1rem; background: var(--card); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; text-decoration: none; color: var(--text); }
header nav { display: flex; flex-wrap: wrap; gap: .2rem; flex: 1; }
header nav a { padding: .3rem .7rem; border-radius: 6px; text-decoration: none; color: var(--text); }
header nav a.active, header nav a:hover { background: var(--bg); color: var(--accent); }
@media (max-width: 640px) { header nav { order: 3; flex-basis: 100%; } .who { margin-left: auto; } }
.who { display: flex; gap: .8rem; align-items: center; font-size: .9rem; }

main { max-width: 1000px; margin: 0 auto; padding: 1.2rem 1rem 3rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.2rem; margin-bottom: 1rem; }
.narrow { max-width: 420px; margin: 2rem auto; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem; }
.grid .card { margin: 0; }

.head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.toolbar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: 1rem; }
.toolbar input[type=search] { flex: 1; min-width: 160px; }
.tabs { display: inline-flex; flex-wrap: wrap; background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 2px; }
.tabs a { padding: .25rem .7rem; border-radius: 6px; text-decoration: none; color: var(--muted); font-size: .9rem; }
.tabs a.active { background: var(--accent); color: var(--accent-ink); }

input, textarea, select, button { font: inherit; color: inherit; }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=tel],
input[type=date], input[type=time], input[type=number], textarea, select {
  width: 100%; padding: .5rem .6rem; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); }
textarea { resize: vertical; }
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; }
.field { margin-bottom: 1rem; border: 0; padding: 0; }
.field > label, legend { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .25rem; }
label.check { display: inline-flex; gap: .4rem; align-items: center; font-weight: normal; margin-right: 1rem; }
.members { margin-top: .5rem; padding: .5rem .7rem; background: var(--bg); border-radius: 6px; }
.members small { display: block; color: var(--muted); }
.has-err input, .has-err textarea { border-color: var(--danger); }
small.err { color: var(--danger); }

button, .button { display: inline-block; padding: .45rem 1rem; border-radius: 6px; border: 1px solid var(--line);
  background: var(--card); cursor: pointer; text-decoration: none; color: var(--text); }
.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
button.link { background: none; border: 0; padding: 0; color: var(--accent); text-decoration: underline; }
.actions { display: flex; flex-wrap: wrap; gap: .8rem; align-items: center; margin-top: 1rem; }
form.inline { display: inline-flex; gap: .5rem; align-items: center; margin: 0; }
.small { font-size: .85rem; }

.flash { padding: .6rem .9rem; border-radius: 6px; }
.flash.ok { background: var(--ok-bg); } .flash.err { background: var(--err-bg); } .flash.warn { background: var(--warn-bg); }

.table-wrap { margin-bottom: 1rem; overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
table.list { width: 100%; border-collapse: collapse; }
table.list th, table.list td { text-align: left; padding: .55rem .8rem; border-bottom: 1px solid var(--line); vertical-align: top; }
table.list th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
table.list tr:last-child td { border-bottom: 0; }
td.num, td.nowrap { white-space: nowrap; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }

.badge { display: inline-block; font-size: .75rem; padding: .05rem .5rem; border-radius: 99px; background: var(--bg); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.vis-private { border-color: var(--muted); }
.vis-all { color: var(--accent); border-color: var(--accent); }
.meta, .crumbs, .empty { color: var(--muted); font-size: .9rem; }
dl { display: grid; grid-template-columns: max-content 1fr; gap: .4rem 1.2rem; margin: 1rem 0 0; }
dt { color: var(--muted); } dd { margin: 0; } dd.text { white-space: normal; }
@media (max-width: 560px) { dl { grid-template-columns: 1fr; } dt { margin-top: .5rem; } }

ul.plain { list-style: none; padding: 0; margin: 0 0 .8rem; }
ul.plain li { padding: .3rem 0; border-bottom: 1px dashed var(--line); }
ul.plain .date { display: inline-block; min-width: 6.5em; color: var(--muted); font-variant-numeric: tabular-nums; }

/* Graphique santé */
.chart-head { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: space-between; margin-bottom: .6rem; }
.chart figure { margin: 0; }
.chart svg { width: 100%; height: auto; display: block; }
.chart .gridline { stroke: var(--line); stroke-width: 1; }
.chart .tick { stroke: var(--muted); }
.chart .axis { fill: var(--muted); font-size: 11px; }
.chart polyline { stroke-width: 2; stroke-linejoin: round; }
.chart polyline.s0 { stroke: var(--s0); } .chart polyline.s1 { stroke: var(--s1); }
.chart circle.s0 { fill: var(--s0); } .chart circle.s1 { fill: var(--s1); }
figcaption { display: flex; gap: 1.2rem; font-size: .85rem; color: var(--muted); margin-top: .3rem; }
.key i { display: inline-block; width: 14px; height: 3px; vertical-align: middle; margin-right: .4rem; }
.key i.s0 { background: var(--s0); } .key i.s1 { background: var(--s1); }

/* Saisie par niveaux (boutons-pastilles) et durée h/min */
.field > .label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .35rem; }
.levels { display: flex; flex-wrap: wrap; gap: .4rem; }
.levels label { position: relative; }
.levels input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.levels span { display: inline-block; padding: .4rem .85rem; border: 1px solid var(--line); border-radius: 99px;
  background: var(--bg); cursor: pointer; font-size: .92rem; user-select: none; }
.levels label:hover span { border-color: var(--accent); }
.levels input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.levels input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.duration { display: flex; align-items: center; gap: .4rem; }
.duration input[type=number] { width: 5.5em; }
.duration span { color: var(--muted); margin-right: .6rem; }
.lvl { display: inline-block; font-size: .85rem; padding: .05rem .55rem; border-radius: 99px; background: var(--bg); border: 1px solid var(--line); white-space: nowrap; }

.actions-inline { display: inline-flex; flex-wrap: wrap; gap: .5rem; }
details.help { margin-top: 1.2rem; font-size: .92rem; }
details.help summary { cursor: pointer; color: var(--accent); }
details.help li { margin: .3rem 0; }

/* Frise */
.frise { padding: .8rem; }
.frise-bar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: .6rem; }
.frise-bar input[type=search] { flex: 1; min-width: 140px; width: auto; }
.frise-filters { display: flex; flex-wrap: wrap; gap: .3rem .9rem; margin-bottom: .5rem; font-size: .9rem; }
.fchip { display: inline-flex; align-items: center; gap: .35rem; cursor: pointer; }
.fchip .dot { display: inline-block; width: .75rem; height: .75rem; border-radius: 3px; background: currentColor; border: 0; }
.cat-agenda { color: var(--muted); border-color: var(--muted); }
#fmain { display: block; width: 100%; touch-action: none; user-select: none; cursor: grab; border-radius: 6px; outline-offset: 2px; }
#fmain:active { cursor: grabbing; }
#fover { display: block; width: 100%; margin-top: .4rem; touch-action: none; cursor: pointer; }
#fmain text, #fover text { font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
#fmain .tick-minor, #fover .tick-minor { fill: var(--muted); font-size: 11px; }
#fmain .tick-major { fill: var(--text); font-size: 12px; font-weight: 600; }
#fmain .grid-minor { stroke: var(--line); stroke-width: 1; }
#fmain .grid-major, #fover .grid-major { stroke: var(--muted); stroke-opacity: .45; stroke-width: 1; }
#fmain .axis-line { stroke: var(--muted); }
#fmain .lane-alt { fill: var(--bg); }
#fmain .lane-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
#fmain .today { stroke: var(--danger); stroke-width: 1.5; stroke-dasharray: 4 3; }
#fmain .lbl { fill: var(--text); font-size: 12px; pointer-events: none; }
#fmain .lbl.in { fill: #fff; font-weight: 600; }
#fmain .lbl.muted { fill: var(--muted); }
#fmain .item { cursor: pointer; }
#fmain .item:hover rect, #fmain .item:focus rect, #fmain .item.sel rect { stroke: var(--text); stroke-width: 1.5; }
#fmain .item:focus { outline: none; }
#fover .ov-bg { fill: var(--bg); }
#fover .ov-win { fill: var(--accent); fill-opacity: .15; stroke: var(--accent); stroke-width: 1.5; }
.frise-help { margin: .4rem 0 0; font-size: .8rem; }
.frise-detail { position: relative; margin-top: .8rem; padding: 1rem 1.2rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); }
.frise-detail h2 { margin: .4rem 0 .2rem; }
.frise-detail p { margin: .3rem 0; }
.frise-detail .notes { white-space: pre-line; }
.frise-detail .close { position: absolute; top: .4rem; right: .5rem; border: 0; background: none; font-size: 1.3rem; line-height: 1; padding: .2rem .5rem; }

/* Filtres de liste et suppression rapide */
.list-filters { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .9rem; flex-basis: 100%; font-size: .9rem; }
.list-filters .fchip { display: inline-flex; align-items: center; gap: .35rem; cursor: pointer; }
.list-filters .dot { display: inline-block; width: .75rem; height: .75rem; border-radius: 3px; background: currentColor; }
.icon-del { padding: .1rem .55rem; font-size: 1.1rem; line-height: 1.2; color: var(--muted); background: none; border: 1px solid transparent; }
.icon-del:hover, .icon-del:focus-visible { color: var(--danger); border-color: var(--danger); }
form.undo { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
