:root {
  --bg: #f6f4ef; --card: #fff; --ink: #1f2a22; --muted: #6b746c; --line: #e4e0d6;
  --brand: #3f5b47; --brand-2: #e7efe8; --accent: #b8864b; --red: #b4443a; --red-2: #f8e6e3;
  --amber: #a5701b; --amber-2: #fbf0dc; --blue: #2f5d8a; --blue-2: #e6eef7; --green: #2f7a4b; --green-2: #e3f2e8;
  --r: 12px; --sh: 0 1px 2px rgba(0,0,0,.04), 0 2px 8px rgba(0,0,0,.04);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 15px; -webkit-text-size-adjust: 100%; }
a { color: var(--brand); }
.boot { padding: 40vh 0; text-align: center; color: var(--muted); }

.layout { display: flex; min-height: 100vh; }
.side { width: 230px; background: var(--card); border-right: 1px solid var(--line); padding: 18px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 2px; }
.logo { font-weight: 700; font-size: 17px; padding: 4px 10px 18px; color: var(--brand); letter-spacing: -.2px; }
.logo small { display: block; font-weight: 500; color: var(--muted); font-size: 12px; }
.nav a { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; border-radius: 9px; color: var(--ink); text-decoration: none; font-weight: 500; }
.nav a:hover { background: var(--bg); }
.nav a.on { background: var(--brand-2); color: var(--brand); }
.nav .badge { background: var(--red); color: #fff; border-radius: 99px; font-size: 12px; padding: 1px 8px; font-weight: 600; }
.side .foot { margin-top: auto; font-size: 13px; color: var(--muted); padding: 10px; }
.main { flex: 1; padding: 26px 30px 90px; max-width: 1180px; min-width: 0; }
h1 { font-size: 24px; margin: 0 0 4px; letter-spacing: -.3px; }
h2 { font-size: 17px; margin: 0 0 12px; }
h3 { font-size: 15px; margin: 0 0 8px; }
.sub { color: var(--muted); margin: 0 0 20px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; box-shadow: var(--sh); margin-bottom: 16px; }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; box-shadow: var(--sh); }
.kpi .v { font-size: 26px; font-weight: 700; letter-spacing: -.5px; }
.kpi .l { color: var(--muted); font-size: 13px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.stack > * + * { margin-top: 10px; }

.btn { border: 1px solid var(--line); background: var(--card); color: var(--ink); padding: 9px 14px; border-radius: 9px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.btn:hover { border-color: #cfc9bb; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.danger { color: var(--red); }
.btn.wa { background: #1f9d55; border-color: #1f9d55; color: #fff; }
.btn.sm { padding: 6px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
input, select, textarea { font: inherit; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; background: #fff; color: var(--ink); width: 100%; }
textarea { min-height: 120px; resize: vertical; line-height: 1.45; }
label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
.field { margin-bottom: 12px; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 500; color: var(--ink); font-size: 14px; margin: 0; }
.check input { width: auto; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); border-radius: 99px; padding: 6px 12px; cursor: pointer; background: #fff; font-size: 14px; user-select: none; }
.chip.on { background: var(--brand); color: #fff; border-color: var(--brand); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 10px 14px; text-decoration: none; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.on { color: var(--brand); border-color: var(--brand); }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); }
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr.click { cursor: pointer; } tr.click:hover td { background: #faf9f5; }
.table-wrap { overflow-x: auto; }

.tag { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--bg); color: var(--muted); white-space: nowrap; }
.tag.green { background: var(--green-2); color: var(--green); }
.tag.red { background: var(--red-2); color: var(--red); }
.tag.amber { background: var(--amber-2); color: var(--amber); }
.tag.blue { background: var(--blue-2); color: var(--blue); }
.tag.brand { background: var(--brand-2); color: var(--brand); }

.switch { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: var(--r); border: 1px solid var(--line); background: var(--card); }
.switch.on { background: var(--green-2); border-color: #bfdcc9; }
.toggle { position: relative; width: 50px; height: 30px; flex: none; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle span { position: absolute; inset: 0; background: #cfc9bb; border-radius: 99px; transition: .2s; cursor: pointer; }
.toggle span:before { content: ""; position: absolute; width: 24px; height: 24px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.toggle input:checked + span { background: var(--green); }
.toggle input:checked + span:before { transform: translateX(20px); }

.msg { background: var(--bg); border-radius: 10px; padding: 12px 14px; white-space: pre-wrap; line-height: 1.45; font-size: 14px; }
.msg.them { background: var(--blue-2); }
.timeline .it { border-left: 2px solid var(--line); padding: 0 0 14px 14px; position: relative; }
.timeline .it:before { content: ""; position: absolute; left: -6px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--line); }
.timeline .it.reponse:before { background: var(--blue); }
.timeline .it.envoi:before, .timeline .it.relance:before, .timeline .it.reponse_envoyee:before { background: var(--brand); }
.timeline .it.erreur:before { background: var(--red); }
.empty { text-align: center; color: var(--muted); padding: 26px 10px; }
.alert { padding: 12px 14px; border-radius: 10px; background: var(--amber-2); color: #6d4a10; margin-bottom: 14px; font-size: 14px; }
.alert.red { background: var(--red-2); color: var(--red); }
.alert.green { background: var(--green-2); color: var(--green); }
.steps { counter-reset: s; padding: 0; list-style: none; margin: 0; }
.steps li { counter-increment: s; padding: 10px 0 10px 38px; position: relative; border-bottom: 1px solid var(--line); }
.steps li:before { content: counter(s); position: absolute; left: 0; top: 9px; width: 26px; height: 26px; border-radius: 50%; background: var(--brand-2); color: var(--brand); font-weight: 700; display: grid; place-items: center; font-size: 13px; }
.steps li.done:before { content: "✓"; background: var(--green); color: #fff; }
.log { font-size: 13px; }
.log div { padding: 6px 0; border-bottom: 1px solid var(--line); }

.modal-bg { position: fixed; inset: 0; background: rgba(20,25,20,.45); display: flex; align-items: flex-start; justify-content: center; padding: 40px 14px; z-index: 50; overflow-y: auto; }
.modal { background: var(--card); border-radius: 14px; width: 100%; max-width: 720px; padding: 20px; box-shadow: 0 20px 60px rgba(0,0,0,.2); }
.modal .x { float: right; }
#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 11px 16px; border-radius: 10px; font-size: 14px; opacity: 0; transition: .25s; pointer-events: none; z-index: 99; max-width: 90vw; }
#toast.show { opacity: 1; }
.spin { display: inline-block; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: sp .8s linear infinite; vertical-align: -2px; }
@keyframes sp { to { transform: rotate(360deg); } }
.login { max-width: 380px; margin: 12vh auto; }

.bottom-nav { display: none; }
.pcard { display: none; }
@media (max-width: 820px) {
  .side { display: none; }
  .main { padding: 18px 14px 100px; padding-top: calc(18px + env(safe-area-inset-top)); }
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g3, .g2 { grid-template-columns: 1fr; }
  .bottom-nav { display: flex; position: fixed; bottom: 0; left: 0; right: 0; background: var(--card); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); z-index: 40; justify-content: space-around; }
  .bottom-nav a { flex: 1; text-align: center; text-decoration: none; color: var(--muted); font-size: 11px; font-weight: 600; padding: 4px 0; position: relative; }
  .bottom-nav a .ic { display: block; font-size: 20px; line-height: 1.2; }
  .bottom-nav a.on { color: var(--brand); }
  .bottom-nav .badge { position: absolute; top: 0; right: 18%; background: var(--red); color: #fff; border-radius: 99px; font-size: 10px; padding: 0 6px; }
  .hide-m { display: none !important; }
  table.resp { display: none; }
  .pcard { display: block; border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-bottom: 8px; background: #fff; }
  h1 { font-size: 21px; }
  .modal-bg { padding: 0; }
  .modal { border-radius: 0; min-height: 100vh; padding-top: calc(20px + env(safe-area-inset-top)); }
}
