:root {
  --bg: #f6f3ee; --panel: #ffffff; --panel-2: #faf8f4; --ink: #1b1714; --muted: #7d7368; --line: #e8e1d6;
  --gold: #b8925a; --gold-soft: #f5ecdd; --accent: #1b1714;
  --blue: #3563c9; --blue-soft: #e8eefb; --green: #2f8a57; --green-soft: #e3f3e9;
  --amber: #b87514; --amber-soft: #fbf0dc; --red: #c2412d; --red-soft: #fbe8e4; --violet: #7a4fc4; --violet-soft: #efe8fb;
  --grey-soft: #eeebe6;
  --radius: 14px; --shadow: 0 1px 2px rgba(27,23,20,.05), 0 8px 24px -16px rgba(27,23,20,.25);
  --sans: "Inter", system-ui, -apple-system, sans-serif; --serif: "Fraunces", Georgia, serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141210; --panel: #1d1a17; --panel-2: #23201c; --ink: #f1ebe2; --muted: #a39887; --line: #34302a;
    --gold-soft: #3a2f20; --blue-soft: #1f2a40; --green-soft: #1b3326; --amber-soft: #3b2c14; --red-soft: #3d1f19;
    --violet-soft: #2c2240; --grey-soft: #2a2622; --accent: #e9d9bd;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px -16px rgba(0,0,0,.6);
  }
}
:root[data-theme="dark"] {
  --bg: #141210; --panel: #1d1a17; --panel-2: #23201c; --ink: #f1ebe2; --muted: #a39887; --line: #34302a;
  --gold-soft: #3a2f20; --blue-soft: #1f2a40; --green-soft: #1b3326; --amber-soft: #3b2c14; --red-soft: #3d1f19;
  --violet-soft: #2c2240; --grey-soft: #2a2622; --accent: #e9d9bd;
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.5 var(--sans); background: var(--bg); color: var(--ink); }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; }
.hidden { display: none !important; }

/* ---------- structure ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: #15120f; color: #e9e1d4; padding: 20px 14px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.side .brand { font-family: var(--serif); letter-spacing: .25em; font-size: 16px; padding: 4px 10px 18px; }
.side .brand b { color: var(--gold); font-weight: 500; }
.side a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; text-decoration: none; color: #cbbfae; }
.side a:hover { background: rgba(255,255,255,.06); color: #fff; }
.side a.on { background: rgba(184,146,90,.18); color: #f3e3c6; }
.side a .count { margin-left: auto; background: var(--gold); color: #15120f; border-radius: 999px; font-size: 11px; font-weight: 700; padding: 1px 7px; }
.side .grow { flex: 1; }
.side .who { font-size: 12px; color: #988b79; padding: 10px 12px; border-top: 1px solid rgba(255,255,255,.08); }
.side .who button { background: none; border: 0; color: #cbbfae; padding: 0; cursor: pointer; text-decoration: underline; }
.main { min-width: 0; }
.top { display: flex; align-items: center; gap: 12px; padding: 14px 28px; border-bottom: 1px solid var(--line); background: var(--panel); position: sticky; top: 0; z-index: 5; }
.top .menu { display: none; }
.search { position: relative; flex: 1; max-width: 520px; }
.search input { width: 100%; padding: 9px 14px 9px 36px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel-2); }
.search::before { content: "⌕"; position: absolute; left: 13px; top: 6px; color: var(--muted); font-size: 18px; }
.search .results { position: absolute; top: 44px; left: 0; right: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); max-height: 60vh; overflow: auto; z-index: 20; }
.search .results a { display: flex; gap: 10px; justify-content: space-between; padding: 10px 14px; text-decoration: none; border-bottom: 1px solid var(--line); }
.search .results a:hover, .search .results a.sel { background: var(--panel-2); }
.venue-switch { display: flex; gap: 4px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.venue-switch button { border: 0; background: none; padding: 5px 12px; border-radius: 999px; cursor: pointer; color: var(--muted); }
.venue-switch button.on { background: var(--accent); color: var(--bg); }
.page { padding: 26px 28px 60px; max-width: 1400px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { font-family: var(--serif); font-weight: 500; font-size: 30px; }
.page-head .sub { color: var(--muted); }
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 30; left: 0; top: 0; width: 250px; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; }
  .top { padding: 10px 16px; flex-wrap: wrap; }
  .top .menu { display: block; }
  .page { padding: 18px 16px 50px; }
  .venue-switch { order: 3; }
}

/* ---------- composants ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--panel); padding: 8px 14px; border-radius: 10px; cursor: pointer; text-decoration: none; white-space: nowrap; font-weight: 500; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--bg); }
.btn.gold { background: var(--gold); border-color: var(--gold); color: #15120f; }
.btn.danger { color: var(--red); border-color: var(--red-soft); }
.btn.small { padding: 4px 10px; font-size: 12px; border-radius: 8px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.card-h h2 { font-size: 15px; font-weight: 600; display: flex; gap: 8px; align-items: center; }
.card-b { padding: 14px 18px; }
.empty { color: var(--muted); padding: 18px; text-align: center; }
.grid { display: grid; gap: 18px; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); }
@media (max-width: 500px) { .g2 { grid-template-columns: 1fr; } }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; text-decoration: none; display: block; }
.kpi .v { font-size: 30px; font-weight: 600; font-variant-numeric: tabular-nums; }
.kpi .l { color: var(--muted); font-size: 13px; }
.kpi.alert .v { color: var(--red); }

.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--grey-soft); color: var(--muted); }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.st-nouvelle { background: var(--blue-soft); color: var(--blue); }
.st-a_traiter { background: var(--amber-soft); color: var(--amber); }
.st-attente_client { background: var(--violet-soft); color: var(--violet); }
.st-option { background: var(--gold-soft); color: var(--gold); }
.st-confirmee { background: var(--green-soft); color: var(--green); }
.st-annulee { background: var(--grey-soft); color: var(--muted); }
.tag { display: inline-block; padding: 1px 8px; border-radius: 6px; font-size: 11px; font-weight: 600; background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); }
.ok { color: var(--green); } .warn { color: var(--amber); } .bad { color: var(--red); } .muted { color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--blue); display: inline-block; }

.list-row { display: flex; align-items: center; gap: 12px; padding: 11px 18px; border-bottom: 1px solid var(--line); text-decoration: none; }
.list-row:last-child { border-bottom: 0; }
.list-row:hover { background: var(--panel-2); }
.list-row .main-txt { flex: 1; min-width: 0; }
.list-row .t { font-weight: 600; }
.list-row .s { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

table.t { width: 100%; border-collapse: collapse; }
table.t th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--panel-2); position: sticky; top: 0; }
table.t td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.t tr.click { cursor: pointer; }
table.t tr.click:hover td { background: var(--panel-2); }
table.t tr.unread td:first-child + td { font-weight: 700; }
.table-wrap { overflow: auto; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; align-items: center; }
.filters select, .filters input, .field input, .field select, .field textarea {
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 600; }
.field input, .field select, .field textarea { color: var(--ink); font-size: 14px; font-weight: 400; width: 100%; }
.field textarea { min-height: 80px; resize: vertical; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.check { display: inline-flex; gap: 6px; align-items: center; font-size: 13px; color: var(--ink); font-weight: 500; }
.bulkbar { position: sticky; bottom: 16px; margin-top: 12px; display: flex; gap: 8px; align-items: center; background: var(--accent); color: var(--bg); padding: 10px 14px; border-radius: 12px; box-shadow: var(--shadow); flex-wrap: wrap; }
.bulkbar .btn { background: transparent; color: var(--bg); border-color: rgba(255,255,255,.3); }

/* ---------- fiche ---------- */
.fiche { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(320px, 1fr); gap: 18px; align-items: start; }
@media (max-width: 1100px) { .fiche { grid-template-columns: 1fr; } }
.fiche-head { display: flex; gap: 14px; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; margin-bottom: 18px; }
.fiche-head h1 { font-family: var(--serif); font-weight: 500; font-size: 28px; }
.fiche-head .meta { color: var(--muted); display: flex; flex-wrap: wrap; gap: 10px; margin-top: 4px; align-items: center; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 1px; background: var(--line); border-radius: 12px; overflow: hidden; margin-bottom: 18px; border: 1px solid var(--line); }
.facts div { background: var(--panel); padding: 10px 14px; }
.facts .l { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.facts .v { font-weight: 600; overflow-wrap: anywhere; }
.convo { display: flex; flex-direction: column; gap: 10px; padding: 16px 18px; max-height: 560px; overflow: auto; background: var(--panel-2); }
.msg { max-width: 82%; padding: 10px 14px; border-radius: 14px; overflow-wrap: anywhere; }
.msg .txt { white-space: pre-wrap; }
.msg.in { background: var(--panel); border: 1px solid var(--line); align-self: flex-start; border-bottom-left-radius: 4px; }
.msg.out { background: var(--gold-soft); align-self: flex-end; border-bottom-right-radius: 4px; }
.msg.draft { border: 1px dashed var(--gold); background: transparent; }
.msg.sys { align-self: center; background: none; color: var(--muted); font-size: 12px; padding: 2px; }
.msg .h { font-size: 11px; color: var(--muted); margin-bottom: 4px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.msg.unread { box-shadow: 0 0 0 2px var(--blue); }
.composer { padding: 14px 18px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.composer textarea { min-height: 130px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); resize: vertical; }
.composer input { padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
.composer .actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 8px 0 8px 18px; border-left: 2px solid var(--line); position: relative; margin-left: 6px; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 13px; width: 10px; height: 10px; border-radius: 50%; background: var(--panel); border: 2px solid var(--gold); }
.timeline .d { font-size: 12px; color: var(--muted); }
.timeline .chg { font-size: 12px; color: var(--muted); margin: 2px 0 0; padding-left: 14px; }
.note { padding: 10px 12px; background: var(--amber-soft); border-radius: 10px; margin-bottom: 8px; white-space: pre-wrap; }
.note .d { font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.tabbar { display: flex; gap: 2px; border-bottom: 1px solid var(--line); padding: 0 12px; overflow-x: auto; }
.tabbar button { border: 0; background: none; padding: 12px 12px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabbar button.on { color: var(--ink); border-color: var(--gold); font-weight: 600; }
.dep-steps { display: flex; gap: 4px; margin: 8px 0 12px; }
.dep-steps span { flex: 1; height: 5px; border-radius: 3px; background: var(--line); }
.dep-steps span.on { background: var(--green); }

/* ---------- calendrier ---------- */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.cal .dh { padding: 8px; font-size: 12px; color: var(--muted); text-transform: uppercase; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--panel-2); }
.cal .day { min-height: 116px; padding: 6px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--panel); }
.cal .day.out { background: var(--panel-2); opacity: .55; }
.cal .day.today .n { background: var(--gold); color: #15120f; border-radius: 999px; padding: 0 7px; }
.cal .n { font-size: 12px; font-weight: 600; display: inline-block; margin-bottom: 4px; }
.cal .ev { display: block; font-size: 12px; padding: 3px 6px; border-radius: 6px; margin-bottom: 3px; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border-left: 3px solid currentColor; }
.cal .more { font-size: 11px; color: var(--muted); }
@media (max-width: 760px) { .cal .day { min-height: 70px; } .cal .ev { font-size: 0; height: 6px; padding: 0; margin: 2px 0; } }
.src-Joy { box-shadow: inset -3px 0 0 #e0457b; }
.src-Réserver { box-shadow: inset -3px 0 0 #3a8fd6; }
.src-Kactus { box-shadow: inset -3px 0 0 #32a36b; }

/* ---------- graphiques ---------- */
.bars { display: flex; flex-direction: column; gap: 8px; }
.bar { display: grid; grid-template-columns: 140px 1fr 50px; gap: 10px; align-items: center; font-size: 13px; }
.bar .track { background: var(--panel-2); border-radius: 6px; height: 12px; overflow: hidden; }
.bar .fill { height: 100%; background: var(--gold); border-radius: 6px; }
.bar .n { text-align: right; font-variant-numeric: tabular-nums; }
.cols { display: flex; align-items: flex-end; gap: 6px; height: 180px; padding-top: 10px; }
.cols .c { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; font-size: 11px; color: var(--muted); min-width: 0; }
.cols .stack { width: 100%; max-width: 42px; display: flex; flex-direction: column-reverse; border-radius: 6px 6px 0 0; overflow: hidden; }
.cols .stack .a { background: var(--line); }
.cols .stack .b { background: var(--green); }

/* ---------- divers ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(15,12,10,.5); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.modal { background: var(--panel); border-radius: 16px; width: min(560px, 100%); max-height: 90vh; overflow: auto; box-shadow: 0 30px 80px -20px rgba(0,0,0,.5); }
.modal .card-b { display: flex; flex-direction: column; gap: 12px; }
.modal .foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 18px; border-top: 1px solid var(--line); }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--accent); color: var(--bg); padding: 11px 18px; border-radius: 12px; z-index: 60; box-shadow: var(--shadow); max-width: 90vw; }
.toast.err { background: var(--red); color: #fff; }
.login { min-height: 100vh; display: grid; place-items: center; background: #15120f; padding: 16px; }
.login form { background: var(--panel); padding: 34px; border-radius: 20px; width: min(380px, 100%); display: flex; flex-direction: column; gap: 14px; }
.login h1 { font-family: var(--serif); font-weight: 500; letter-spacing: .2em; font-size: 20px; text-align: center; }
.login h1 b { color: var(--gold); font-weight: 500; }
.banner { padding: 10px 14px; border-radius: 10px; background: var(--amber-soft); color: var(--amber); margin-bottom: 14px; font-size: 13px; }
.banner.info { background: var(--blue-soft); color: var(--blue); }
.spin { display: inline-block; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: s .7s linear infinite; }
@keyframes s { to { transform: rotate(360deg); } }
.row-flex { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.sep { height: 1px; background: var(--line); margin: 10px 0; }
kbd { font-size: 11px; border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; color: var(--muted); }
