:root {
  --ink: #17202b; --muted: #5b6776; --line: #d9dee5; --bg: #f4f6f8; --card: #fff;
  --brand: #1f2a37; --accent: #0f6e66; --accent-ink: #fff; --accent-soft: #e3f1ef;
  --ok: #17643a; --ok-bg: #e5f4ea; --warn: #8a5300; --warn-bg: #fdf1dc; --err: #a4161a; --err-bg: #fbe5e6;
  --info: #1d4f91; --info-bg: #e5eefa; --radius: 10px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.45; }
a { color: var(--accent); }
h1 { font-size: 1.45rem; margin: 0 0 .25rem; }
h2 { font-size: 1.1rem; margin: 0 0 .6rem; }
h3 { font-size: 1rem; margin: 0 0 .4rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }

/* ---------- en-tête ---------- */
.top { background: var(--brand); color: #fff; position: sticky; top: 0; z-index: 20; }
.top-in { display: flex; align-items: center; gap: 1rem; max-width: 1400px; margin: 0 auto; padding: .55rem 1rem; }
.logo { font-weight: 800; letter-spacing: .08em; color: #fff; text-decoration: none; font-size: 1.1rem; }
.logo small { font-weight: 500; letter-spacing: 0; opacity: .7; font-size: .75rem; margin-left: .3rem; }
.nav { display: flex; gap: .2rem; }
.nav a { color: #dfe5ec; text-decoration: none; padding: .45rem .7rem; border-radius: 8px; font-weight: 500; }
.nav a.on, .nav a:hover { background: rgba(255,255,255,.12); color: #fff; }
.search { flex: 1; max-width: 420px; margin-left: auto; position: relative; }
.search input { width: 100%; border: 0; border-radius: 8px; padding: .5rem .75rem; font-size: .95rem; }
.search-res { position: absolute; top: 110%; left: 0; right: 0; background: #fff; color: var(--ink); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.18); overflow: hidden; }
.search-res a { display: block; padding: .5rem .75rem; text-decoration: none; color: var(--ink); border-bottom: 1px solid var(--line); }
.search-res a:hover, .search-res a.sel { background: var(--accent-soft); }
.me { color: #dfe5ec; font-size: .85rem; display: flex; gap: .5rem; align-items: center; }
.me form { margin: 0; }
.me button { background: none; border: 1px solid rgba(255,255,255,.3); color: #fff; border-radius: 6px; padding: .2rem .5rem; cursor: pointer; }
.demo-band { background: #fff3cd; color: #6b4b00; text-align: center; font-size: .82rem; padding: .25rem; }

/* navigation mobile */
.bottom-nav { display: none; }
@media (max-width: 860px) {
  .nav, .me .who, .logo small { display: none; }
  .bottom-nav { display: flex; position: fixed; bottom: 0; left: 0; right: 0; background: var(--brand); z-index: 30; padding-bottom: env(safe-area-inset-bottom); }
  .bottom-nav a { flex: 1; text-align: center; color: #cfd6de; text-decoration: none; font-size: .72rem; padding: .45rem 0 .5rem; }
  .bottom-nav a b { display: block; font-size: 1.15rem; line-height: 1.2; }
  .bottom-nav a.on { color: #fff; background: rgba(255,255,255,.1); }
  body { padding-bottom: 70px; }
  .search { max-width: none; }
}

main { max-width: 1400px; margin: 0 auto; padding: 1rem; }
.page-head { display: flex; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.page-head .actions { margin-left: auto; display: flex; gap: .5rem; flex-wrap: wrap; }

/* ---------- composants ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem; }
.card.tight { padding: .6rem .8rem; }
.grid { display: grid; gap: 1rem; }
.g2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.g-side { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
@media (max-width: 960px) { .g2, .g3, .g-side { grid-template-columns: minmax(0, 1fr); } }
.kv dd, .m-kv dd { overflow-wrap: anywhere; min-width: 0; }
.card { min-width: 0; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: .35rem; border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: .55rem .9rem; border-radius: 8px; font-size: .95rem; font-weight: 600; text-decoration: none; cursor: pointer; min-height: 42px; }
.btn:hover { border-color: #b7c0cb; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.dark { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.danger { color: var(--err); border-color: #e9b8ba; }
.btn.small { min-height: 32px; padding: .3rem .6rem; font-size: .85rem; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: wait; }
.next-step { display: flex; align-items: center; gap: .8rem; background: var(--accent-soft); border: 1px solid #b9ddd8; border-radius: var(--radius); padding: .75rem 1rem; margin-bottom: 1rem; }
.next-step .lbl { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--accent); font-weight: 700; }

.badge { display: inline-block; font-size: .78rem; font-weight: 600; padding: .12rem .5rem; border-radius: 999px; border: 1px solid transparent; white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; vertical-align: middle; }
.b-neutral { background: #eef1f4; color: #39434f; border-color: #dbe0e6; }
.b-ok { background: var(--ok-bg); color: var(--ok); border-color: #bfe2cb; }
.b-warn { background: var(--warn-bg); color: var(--warn); border-color: #f1d39c; }
.b-err { background: var(--err-bg); color: var(--err); border-color: #f0b9bb; }
.b-info { background: var(--info-bg); color: var(--info); border-color: #bcd2f0; }
.b-demo { background: #fff3cd; color: #6b4b00; border-color: #f0dc9a; }

.flash { padding: .7rem 1rem; border-radius: 8px; margin-bottom: 1rem; font-weight: 500; }
.flash.ok { background: var(--ok-bg); color: var(--ok); }
.flash.err { background: var(--err-bg); color: var(--err); }
.flash.warn { background: var(--warn-bg); color: var(--warn); }

table.list { width: 100%; border-collapse: collapse; background: #fff; }
table.list th { text-align: left; font-size: .8rem; color: var(--muted); font-weight: 600; padding: .5rem .6rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.list td { padding: .55rem .6rem; border-bottom: 1px solid #edf0f3; vertical-align: top; }
table.list tr:hover td { background: #fafbfc; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: .3rem .9rem; margin: 0; }
.kv dt { color: var(--muted); font-size: .88rem; }
.kv dd { margin: 0; font-weight: 500; }

/* ---------- formulaires ---------- */
label { display: block; font-size: .85rem; font-weight: 600; color: #39434f; margin: 0 0 .25rem; }
input, select, textarea { width: 100%; font: inherit; font-size: 16px; padding: .55rem .65rem; border: 1px solid #c7ced7; border-radius: 8px; background: #fff; color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 2px solid #8cc9c1; border-color: var(--accent); }
textarea { min-height: 90px; resize: vertical; }
.field { margin-bottom: .75rem; }
.row { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.check { display: flex; gap: .5rem; align-items: center; font-weight: 500; }
.check input { width: auto; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem; margin: 0 0 1rem; background: #fff; }
legend { font-weight: 700; padding: 0 .3rem; }
.req::after { content: " *"; color: var(--err); }

/* ---------- Aujourd'hui / ma journée ---------- */
.day-card { border-left: 4px solid var(--accent); }
.visit { display: grid; grid-template-columns: 64px 1fr; gap: .8rem; padding: .8rem 0; border-top: 1px solid var(--line); }
.visit:first-of-type { border-top: 0; }
.visit .hour { font-weight: 800; font-size: 1.1rem; }
.visit .hour small { display: block; font-weight: 500; color: var(--muted); font-size: .8rem; }
.visit .acts { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .5rem; }
.leg { font-size: .82rem; margin: .1rem 0 .35rem; }
.leg::before { content: "🚗 "; }
.waze { background: #33ccff; border-color: #33ccff; color: #05202b; }
.call { background: var(--ok); border-color: var(--ok); color: #fff; }
.list-plain { list-style: none; margin: 0; padding: 0; }
.list-plain li { padding: .5rem 0; border-top: 1px solid #edf0f3; display: flex; gap: .6rem; align-items: baseline; flex-wrap: wrap; }
.list-plain li:first-child { border-top: 0; }
.count { background: var(--brand); color: #fff; border-radius: 999px; font-size: .75rem; padding: .05rem .5rem; margin-left: .35rem; }

/* ---------- colonnes ---------- */
.kanban { display: flex; gap: .75rem; overflow-x: auto; padding-bottom: .5rem; align-items: flex-start; }
.kcol { flex: 0 0 250px; background: #e9edf1; border-radius: var(--radius); padding: .5rem; }
.kcol h3 { font-size: .85rem; margin: .2rem .3rem .5rem; display: flex; justify-content: space-between; }
.kcard { display: block; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: .55rem .6rem; margin-bottom: .5rem; text-decoration: none; color: var(--ink); font-size: .88rem; }
.kcard:hover { border-color: var(--accent); }
.kcard .late { color: var(--err); font-weight: 700; }

/* ---------- planning ---------- */
.plan-week { display: grid; grid-template-columns: repeat(6, minmax(150px, 1fr)); gap: .5rem; overflow-x: auto; }
.plan-day { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); min-height: 220px; }
.plan-day h3 { font-size: .85rem; padding: .45rem .6rem; margin: 0; border-bottom: 1px solid var(--line); background: #f8f9fb; border-radius: var(--radius) var(--radius) 0 0; }
.plan-day.today h3 { background: var(--accent-soft); }
.ev { display: block; margin: .4rem; padding: .4rem .5rem; border-radius: 6px; font-size: .82rem; text-decoration: none; color: var(--ink); background: #f1f5f9; border-left: 4px solid var(--c, #64748b); }
.ev.brouillon { background: repeating-linear-gradient(45deg, #fff, #fff 6px, #f3f4f6 6px, #f3f4f6 12px); }
.ev.conflict { outline: 2px solid var(--err); }
.ev .t { font-weight: 700; }
.day-grid { display: grid; gap: 0; overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.day-grid .hcol { font-size: .75rem; color: var(--muted); }
.day-grid .cell-h { height: 56px; border-top: 1px solid #eef1f4; padding: 2px 4px; }
.day-grid .colhead { font-weight: 700; font-size: .85rem; padding: .4rem; border-bottom: 1px solid var(--line); background: #f8f9fb; position: sticky; top: 0; }
.day-grid .lane { position: relative; border-left: 1px solid var(--line); }
.day-grid .lane .ev { position: absolute; inset: 1px 2px; margin: 0; overflow: hidden; }

/* ---------- vérification de créneau ---------- */
.slot-panel { position: sticky; top: 70px; }
.legbox { border: 1px solid var(--line); border-radius: 8px; padding: .6rem .7rem; margin-bottom: .5rem; }
.legbox.ok { border-color: #bfe2cb; background: var(--ok-bg); }
.legbox.juste, .legbox.a_verifier { border-color: #f1d39c; background: var(--warn-bg); }
.legbox.impossible { border-color: #f0b9bb; background: var(--err-bg); }
.legbox .ttl { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; }
.verdict { font-weight: 700; padding: .55rem .7rem; border-radius: 8px; margin-bottom: .6rem; }
.verdict.ok { background: var(--ok-bg); color: var(--ok); }
.verdict.a_verifier { background: var(--warn-bg); color: var(--warn); }
.verdict.conflit { background: var(--err-bg); color: var(--err); }
.timeline { list-style: none; padding: 0; margin: 0; font-size: .85rem; }
.timeline li { padding: .25rem .4rem; border-left: 3px solid #cbd5e1; margin-bottom: .25rem; }
.timeline li.new { border-color: var(--accent); background: var(--accent-soft); font-weight: 700; }
.timeline li.busy { border-color: #94a3b8; color: var(--muted); font-style: italic; }

.history { list-style: none; padding: 0; margin: 0; font-size: .88rem; }
.history li { padding: .4rem 0; border-top: 1px solid #edf0f3; }
.history time { color: var(--muted); font-size: .8rem; display: block; }
.note { border-left: 3px solid var(--line); padding: .3rem .7rem; margin-bottom: .7rem; white-space: pre-wrap; }
.note.compte_rendu { border-color: var(--accent); }
.note.appel { border-color: var(--info); }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: .5rem; }
.photos img { width: 100%; height: 100px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); }
.match { border: 1px solid #f1d39c; background: var(--warn-bg); border-radius: 8px; padding: .6rem .8rem; margin: .4rem 0; }
.sticky-actions { display: none; }
@media (max-width: 860px) {
  .sticky-actions { display: flex; gap: .4rem; position: fixed; bottom: 62px; left: 0; right: 0; padding: .5rem; background: rgba(244,246,248,.96); border-top: 1px solid var(--line); z-index: 25; }
  .sticky-actions .btn { flex: 1; padding: .5rem .3rem; font-size: .9rem; }
  body.has-sticky { padding-bottom: 130px; }
  .slot-panel { position: static; }
}
details > summary { cursor: pointer; font-weight: 600; }
.tabs { display: flex; gap: .3rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; flex-wrap: wrap; }
.tabs a { padding: .5rem .8rem; text-decoration: none; color: var(--muted); font-weight: 600; border-bottom: 3px solid transparent; }
.tabs a.on { color: var(--ink); border-color: var(--accent); }
pre.mail { white-space: pre-wrap; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 1rem; font-family: inherit; }
@media (max-width: 520px) {
  .next-step { flex-wrap: wrap; }
  .next-step .btn { margin-left: 0 !important; width: 100%; }
  .page-head .actions { margin-left: 0; width: 100%; }
  .page-head .actions .btn { flex: 1 1 auto; }
  main { padding: .75rem; }
}
