:root {
  --brand: #576DFF; --brand-ink: #fff; --brand-soft: #EEF1FF;
  --bg: #f7f7f9; --surface: #fff; --text: #16161d; --muted: #6b6b78; --line: #e5e5ec;
  --danger: #dc2626; --ok: #059669; --warn: #d97706;
  --radius: 8px; --shadow: 0 1px 2px rgba(0,0,0,.04), 0 2px 8px rgba(0,0,0,.04);
  font-family: "Jost", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111116; --surface: #1a1a22; --text: #ececf1; --muted: #9a9aa8; --line: #2c2c37; --brand-soft: #2a2140; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.45; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 24px; margin: 0 0 4px; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 18px; margin: 0 0 12px; }
h3 { font-size: 15px; margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.grow { flex: 1; }
.stack > * + * { margin-top: 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 720px) { .grid2 { grid-template-columns: 1fr; } }
.hidden { display: none !important; }

/* Boutons & champs */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--surface); color: var(--text);
  padding: 8px 14px; border-radius: 999px; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--brand); text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn { border: 0; background: transparent; cursor: pointer; color: var(--muted); padding: 6px; border-radius: 6px; font-size: 16px; line-height: 1; }
.icon-btn:hover { background: var(--bg); color: var(--text); }
label { display: block; font-weight: 600; margin-bottom: 4px; font-size: 13px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=url], input[type=tel], input[type=date],
input[type=time], input[type=datetime-local], input[type=color], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; font: inherit; background: var(--surface); color: var(--text);
}
input[type=color] { padding: 2px; height: 38px; width: 60px; }
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: -1px; border-color: transparent; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 500; margin: 0; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--brand); }
.field { margin-bottom: 14px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; font-weight: 400; }

/* Cartes */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card + .card { margin-top: 12px; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; background: var(--bg); color: var(--muted); border: 1px solid var(--line); }
.badge.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.badge.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.badge.brand { color: var(--brand); border-color: color-mix(in srgb, var(--brand) 30%, transparent); }

/* Layout admin */
.app { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--line); padding: 18px 12px; position: sticky; top: 0; height: 100vh; overflow: auto; display: flex; flex-direction: column; }
.logo { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 18px; padding: 4px 10px 18px; }
.logo .dot { width: 26px; height: 26px; border-radius: 8px; background: var(--brand); color: #fff; display: grid; place-items: center; font-size: 14px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; color: var(--text); font-weight: 500; margin-bottom: 2px; }
.nav a:hover { background: var(--bg); text-decoration: none; }
.nav a.active { background: var(--brand-soft); color: var(--brand); font-weight: 700; }
.nav .ico { width: 18px; text-align: center; }
.side .bottom { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); }
.main { padding: 28px 36px; max-width: 1180px; width: 100%; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.tabs { display: flex; gap: 22px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs a { padding: 10px 0; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.active { color: var(--text); border-color: var(--brand); }
.tabs a:hover { text-decoration: none; color: var(--text); }
.mobile-bar { display: none; }
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 30% 0 0; z-index: 50; transform: translateX(-105%); transition: transform .2s; height: 100%; }
  .side.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.25); }
  .mobile-bar { display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 40; }
  .main { padding: 18px 16px; }
}

/* Liste des types d'événements */
.ev-list { display: grid; gap: 12px; }
.ev { display: flex; align-items: center; gap: 14px; background: var(--surface); border: 1px solid var(--line); border-left: 6px solid var(--c, var(--brand)); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.ev.off { opacity: .55; }
.ev .title { font-weight: 700; font-size: 15px; cursor: pointer; }
.ev .meta { color: var(--muted); font-size: 13px; }
@media (max-width: 640px) { .ev { flex-wrap: wrap; } }

/* Tableaux */
.table { width: 100%; border-collapse: collapse; background: var(--surface); }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; }
.table tr.click:hover td { background: var(--bg); cursor: pointer; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }

/* Réunions */
.day-group h3 { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 18px 0 8px; }
.meeting { display: grid; grid-template-columns: 150px 1fr auto; gap: 14px; align-items: center; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 8px; cursor: pointer; }
.meeting:hover { border-color: var(--brand); }
.meeting .dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; background: var(--c, var(--brand)); margin-right: 6px; vertical-align: -1px; }
@media (max-width: 640px) { .meeting { grid-template-columns: 1fr; } }

/* Modale / panneau */
.overlay { position: fixed; inset: 0; background: rgba(10,10,20,.45); z-index: 100; display: flex; justify-content: flex-end; }
.overlay.center { justify-content: center; align-items: center; padding: 16px; }
.panel { background: var(--surface); width: min(640px, 100%); height: 100%; overflow: auto; padding: 24px; box-shadow: -10px 0 40px rgba(0,0,0,.2); }
.panel.wide { width: min(860px, 100%); }
.modal { background: var(--surface); width: min(520px, 100%); max-height: 92vh; overflow: auto; padding: 22px; border-radius: 14px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; gap: 10px; }
.section { border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 12px; }
.section > summary { padding: 14px 16px; font-weight: 700; cursor: pointer; list-style: none; display: flex; justify-content: space-between; }
.section > summary::after { content: "▾"; color: var(--muted); }
.section[open] > summary::after { content: "▴"; }
.section > .body { padding: 0 16px 16px; }

/* Disponibilités */
.week-row { display: grid; grid-template-columns: 110px 1fr; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); align-items: start; }
.ranges .r { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.ranges input[type=time] { width: 120px; }

/* Stats */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi .v { font-size: 28px; font-weight: 800; }
.kpi .l { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.bar { height: 8px; background: var(--bg); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--brand); border-radius: 99px; }
.heat { display: grid; grid-template-columns: 40px repeat(24, 1fr); gap: 2px; font-size: 10px; color: var(--muted); }
.heat .c { aspect-ratio: 1; border-radius: 3px; background: var(--brand); }

/* Toast */
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #16161d; color: #fff; padding: 10px 18px; border-radius: 999px; z-index: 200; font-weight: 600; box-shadow: 0 8px 30px rgba(0,0,0,.25); }
.toast.err { background: var(--danger); }
.empty { text-align: center; padding: 40px 20px; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); background: var(--surface); }
code, .code { font-family: ui-monospace, Consolas, monospace; font-size: 12px; background: var(--bg); padding: 2px 6px; border-radius: 4px; border: 1px solid var(--line); }
pre.code { padding: 10px; white-space: pre-wrap; word-break: break-all; }
.swatches { display: flex; gap: 6px; flex-wrap: wrap; }
.swatches button { width: 26px; height: 26px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; }
.swatches button.sel { border-color: var(--text); }
.q-item { border: 1px solid var(--line); border-radius: 8px; padding: 12px; margin-bottom: 8px; background: var(--bg); }

/* Auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth .card { width: min(420px, 100%); }
.page-head select { width: auto; }
