:root {
  --brand: #4f46e5;
  --brand-dark: #4338ca;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #f8fafc;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
}
.wrap { max-width: 64rem; margin: 0 auto; padding: 1.5rem 1rem; }
h1 { font-size: 1.6rem; margin: 0 0 .25rem; }
h2 { font-size: 1.15rem; margin: 0 0 1rem; }
.muted { color: var(--muted); }
.small { font-size: .8rem; }
.center { text-align: center; }
.accent { color: var(--brand-dark); }
.maybe { color: #b45309; }
.hide-sm { display: none; }
.link, a.link { color: var(--brand-dark); text-decoration: none; }
.link:hover { text-decoration: underline; }

/* Barre du haut */
.topbar { background: #fff; border-bottom: 1px solid var(--line); }
.topbar-in { display: flex; align-items: center; justify-content: space-between; }
.brand { font-weight: 700; color: var(--ink); text-decoration: none; font-size: 1.1rem; }
.topbar-right { display: flex; align-items: center; gap: 1rem; }

/* Cartes */
.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: .75rem;
  padding: 1.25rem;
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
  margin-bottom: 1.25rem;
}
.card-link { display: block; text-decoration: none; color: inherit; transition: border-color .15s, box-shadow .15s; }
.card-link:hover { border-color: #a5b4fc; box-shadow: 0 4px 12px rgba(0,0,0,.06); }

/* Boutons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  border: 1px solid transparent; border-radius: .5rem;
  padding: .5rem .9rem; font-size: .9rem; font-weight: 500;
  cursor: pointer; text-decoration: none; transition: background .15s;
}
.btn-sm { padding: .3rem .55rem; font-size: .85rem; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.btn-light { background: #fff; border-color: var(--line); color: #334155; }
.btn-light:hover { background: #f1f5f9; }
.btn-danger { background: #fff; border-color: #fecaca; color: #b91c1c; }
.btn-danger:hover { background: #fef2f2; }

/* Formulaires */
.stack { display: flex; flex-direction: column; gap: 1rem; }
.label { display: block; font-size: .85rem; font-weight: 500; margin-bottom: .25rem; }
.input {
  width: 100%; border: 1px solid #cbd5e1; border-radius: .5rem;
  padding: .55rem .7rem; font: inherit; background: #fff;
}
.input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(79,70,229,.15); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .8rem; }
.alert { background: #fef2f2; color: #b91c1c; padding: .6rem .8rem; border-radius: .5rem; margin: 0; }
.row-end { display: flex; justify-content: flex-end; gap: .5rem; }
.row-end-tight { display: flex; align-items: flex-end; gap: .75rem; }

/* Mise en page */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.grid2 { display: grid; gap: 1.25rem; grid-template-columns: 1fr; }
.grid2-tight { display: grid; gap: .75rem; grid-template-columns: 1fr 1fr; }
.stat-row { display: flex; gap: 1rem; margin-top: 1rem; font-size: .9rem; color: #475569; }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; margin-bottom: 1.25rem; }
.stat { text-align: left; margin: 0; }
.stat-num { font-size: 1.8rem; font-weight: 700; }
.stat-lbl { font-size: .7rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-top: .25rem; }

/* Listes */
.list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: .5rem; }
.list-item { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .6rem .8rem; border-top: 1px solid var(--line); }
.list-item:first-child { border-top: none; }
.inv { align-items: flex-start; }
.inv-main { min-width: 0; flex: 1; }
.inv-actions { display: flex; gap: .4rem; align-items: center; }
.trunc-link { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.tag { font-size: .7rem; padding: .1rem .5rem; border-radius: 999px; background: #f1f5f9; color: #475569; margin-left: .4rem; }
.tag-ok { background: #dcfce7; color: #166534; }

/* Matrice de disponibilités */
.table-scroll { overflow-x: auto; }
.matrix { border-collapse: collapse; width: 100%; font-size: .9rem; }
.matrix th, .matrix td { border-left: 1px solid var(--line); padding: .5rem; text-align: center; }
.matrix thead th { border-bottom: 1px solid var(--line); font-weight: 600; color: #475569; }
.matrix .sticky-l { position: sticky; left: 0; background: #fff; text-align: left; min-width: 12rem; border-left: none; }
.matrix tbody tr { border-top: 1px solid #f1f5f9; }
.col-count { background: #eef2ff; color: var(--brand-dark); }
.trunc { display: inline-block; max-width: 6rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
.cell { font-weight: 700; }
.cell-yes { background: #dcfce7; color: #166534; }
.cell-maybe { background: #fef3c7; color: #92400e; }
.cell-no { background: #f8fafc; color: #cbd5e1; }

/* Auth / invite */
.auth { max-width: 24rem; margin: 4rem auto 0; }
.auth-title { text-align: center; }
.invite { max-width: 40rem; margin: 0 auto; }
.eyebrow { color: var(--brand-dark); font-weight: 600; font-size: .85rem; margin: 0 0 .25rem; }

/* Choix de disponibilité (invite) */
.avail { list-style: none; margin: 0; padding: 0; }
.avail-row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .75rem 0; border-bottom: 1px solid #f1f5f9; flex-wrap: wrap; }
.avail-row:last-child { border-bottom: none; }
.choices { display: flex; gap: .4rem; }
.choice { border: 1px solid #cbd5e1; background: #fff; border-radius: .5rem; padding: .35rem .7rem; font-size: .85rem; cursor: pointer; }
.choice-yes.on { background: #16a34a; border-color: #16a34a; color: #fff; }
.choice-maybe.on { background: #f59e0b; border-color: #f59e0b; color: #fff; }
.choice-no.on { background: #64748b; border-color: #64748b; color: #fff; }

.danger { color: #dc2626; }

/* Créneaux : édition / duplication / réordonnancement */
.slot-item { display: block; }
.slot-item.dragging { opacity: .45; background: #eef2ff; }
.slot-top { display: flex; align-items: center; gap: .6rem; }
.slot-info { flex: 1; min-width: 0; }
.drag-handle { cursor: grab; color: #94a3b8; font-size: 1.1rem; line-height: 1; user-select: none; flex-shrink: 0; }
.drag-handle:active { cursor: grabbing; }
.slot-actions { display: flex; gap: .4rem; align-items: center; flex-shrink: 0; }
.slot-edit { margin-top: .6rem; }
.slot-edit > summary { list-style: none; }
.slot-edit > summary::-webkit-details-marker { display: none; }
.slot-edit[open] > summary { margin-bottom: .25rem; }

/* Bandeau mode gestion */
.banner { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; padding: .6rem .9rem; border-radius: .5rem; margin-bottom: 1.25rem; font-size: .9rem; }

/* Lien partagé */
.share { border-color: #c7d2fe; background: #eef2ff; }
.share-row { display: flex; gap: .5rem; margin-top: .75rem; flex-wrap: wrap; }
.share-row .input { flex: 1; min-width: 12rem; }

/* Case « Je m'inscris » */
.signup { display: inline-flex; align-items: center; gap: .45rem; padding: .4rem .7rem; border: 1px solid #cbd5e1; border-radius: .5rem; cursor: pointer; white-space: nowrap; background: #fff; }
.signup input { width: 1.1rem; height: 1.1rem; accent-color: var(--brand); }
.signup.is-disabled { opacity: .5; cursor: not-allowed; background: #f8fafc; }

@media (min-width: 640px) {
  .hide-sm { display: inline; }
  .grid2 { grid-template-columns: 1fr 1fr; }
  .stats { grid-template-columns: repeat(4, 1fr); }
}
