:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f1f4;
  --border: #e1e4ea;
  --text: #1f2430;
  --muted: #6b7280;
  --primary: #5b5bd6;
  --primary-hover: #4a4ac4;
  --primary-soft: #ececfd;
  --danger: #dc2626;
  --s-todo: #c4c8d0;
  --s-doing: #fdab3d;
  --s-done: #00c875;
  --s-blocked: #e2445c;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 16px rgba(16, 24, 40, .06);
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171c;
    --surface: #1e2128;
    --surface-2: #262a33;
    --border: #333844;
    --text: #e6e8ee;
    --muted: #9aa1af;
    --primary: #7c7cf0;
    --primary-hover: #8f8ff5;
    --primary-soft: #2a2b4a;
    --s-todo: #5a606d;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
}
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; }

/* ---------- Boutons & champs ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--border); background: var(--surface);
  padding: 7px 12px; border-radius: 8px; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-hover); }
.btn.danger { color: var(--danger); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.icon { padding: 7px 9px; }
.btn:disabled { opacity: .6; cursor: default; }

.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.field label { font-size: 12px; font-weight: 600; color: var(--muted); }
.input, select.input, textarea.input {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--surface); outline: none;
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
textarea.input { resize: vertical; min-height: 80px; }
.row { display: flex; gap: 12px; }
.row > * { flex: 1; min-width: 0; }
.error { color: var(--danger); font-size: 13px; min-height: 18px; margin: 0 0 8px; }

/* ---------- Écran de connexion ---------- */
.auth-wrap { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.auth-card {
  width: 100%; max-width: 380px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 14px; padding: 28px; box-shadow: var(--shadow);
}
.auth-card h1 { font-size: 22px; margin-bottom: 4px; }
.auth-card p.sub { color: var(--muted); margin: 0 0 20px; }
.auth-card .btn { width: 100%; justify-content: center; padding: 10px; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; }
.logo-mark { width: 28px; height: 28px; border-radius: 8px; background: var(--primary); display: grid; place-items: center; }
.auth-card .logo { margin-bottom: 22px; }

/* ---------- Barre du haut ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 10px 20px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.topbar .spacer { flex: 1; }
.week-nav { display: flex; align-items: center; gap: 4px; }
.week-label { font-weight: 600; min-width: 190px; text-align: center; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 8px; padding: 3px; }
.seg button { border: 0; background: transparent; padding: 5px 12px; border-radius: 6px; cursor: pointer; color: var(--muted); }
.seg button.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.08); font-weight: 600; }

.toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 14px 20px 0;
}
.toolbar .input { width: auto; padding: 6px 10px; }
.toolbar .spacer { flex: 1; }

main { padding: 14px 20px 40px; }

/* ---------- Avatars ---------- */
.avatar {
  --c: #6366f1;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--c); color: #fff; font-size: 11px; font-weight: 700;
  display: inline-grid; place-items: center; flex-shrink: 0;
  border: 2px solid var(--surface);
}
.avatar.sm { width: 22px; height: 22px; font-size: 10px; }
.avatar.lg { width: 34px; height: 34px; font-size: 13px; }
.avatars { display: inline-flex; }
.avatars .avatar + .avatar { margin-left: -7px; }
button.avatar-btn { border: 0; background: none; padding: 0; cursor: pointer; border-radius: 50%; }

/* ---------- Vue Tableau (groupes par personne) ---------- */
.group { margin-bottom: 26px; }
.group-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.group-head h2 { font-size: 16px; color: var(--gc); }
.group-head .count { color: var(--muted); font-size: 13px; }
.group-head .collapse { border: 0; background: none; cursor: pointer; color: var(--gc); font-size: 13px; padding: 2px 4px; transition: transform .15s; }
.group.collapsed .collapse { transform: rotate(-90deg); }
.group.collapsed .table { display: none; }
.progress { flex: 0 0 140px; height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; display: flex; }
.progress span { display: block; height: 100%; }

.table {
  background: var(--surface); border: 1px solid var(--border);
  border-left: 5px solid var(--gc); border-radius: var(--radius); overflow: hidden;
}
.tr {
  display: grid; grid-template-columns: minmax(220px, 1fr) 120px 130px 110px 100px 40px;
  align-items: stretch; border-bottom: 1px solid var(--border);
}
.tr:last-child { border-bottom: 0; }
.tr > div { padding: 0 12px; display: flex; align-items: center; min-height: 42px; border-right: 1px solid var(--border); min-width: 0; }
.tr > div:last-child { border-right: 0; justify-content: center; padding: 0; }
.tr.head > div { min-height: 34px; font-size: 12px; color: var(--muted); font-weight: 600; justify-content: center; }
.tr.head > div:first-child { justify-content: flex-start; }
.tr.task:hover { background: var(--surface-2); }
.tr.task .title-cell { gap: 8px; cursor: pointer; }
.tr.task .title-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tr.task.is-done .title-text { text-decoration: line-through; color: var(--muted); }
.tr .center { justify-content: center; }
.tr.add-row > div { border-right: 0; }
.add-input { border: 0; background: transparent; outline: none; width: 100%; padding: 10px 0; color: var(--text); }
.add-input::placeholder { color: var(--muted); }

.chip {
  font-size: 11px; padding: 2px 7px; border-radius: 10px; background: var(--primary-soft);
  color: var(--primary); font-weight: 600; white-space: nowrap; flex-shrink: 0;
}
.desc-dot { color: var(--muted); font-size: 12px; flex-shrink: 0; }

.status-cell { padding: 0 !important; }
.status-pill {
  width: 100%; height: 100%; min-height: 42px; border: 0; cursor: pointer;
  color: #fff; font-weight: 600; font-size: 13px;
}
.status-pill.todo { background: var(--s-todo); }
.status-pill.doing { background: var(--s-doing); }
.status-pill.done { background: var(--s-done); }
.status-pill.blocked { background: var(--s-blocked); }
.status-pill:hover { filter: brightness(1.05); }

.prio { font-size: 12px; font-weight: 600; }
.prio.high { color: var(--s-blocked); }
.prio.normal { color: var(--muted); }
.prio.low { color: var(--muted); opacity: .7; }

.cell-btn { border: 0; background: none; cursor: pointer; width: 100%; height: 100%; min-height: 42px; color: var(--text); }
.cell-btn:hover { background: var(--surface-2); }
.cell-btn.muted { color: var(--muted); }

.empty { color: var(--muted); padding: 30px; text-align: center; }

/* ---------- Vue Semaine (colonnes par jour) ---------- */
.board { display: grid; grid-template-columns: repeat(var(--cols), minmax(190px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.col { background: var(--surface-2); border-radius: var(--radius); padding: 10px; min-height: 200px; display: flex; flex-direction: column; gap: 8px; }
.col.today { box-shadow: inset 0 0 0 2px var(--primary); }
.col.drag-over { background: var(--primary-soft); }
.col-head { display: flex; justify-content: space-between; align-items: baseline; padding: 2px 4px 6px; }
.col-head strong { font-size: 13px; }
.col-head span { color: var(--muted); font-size: 12px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px; cursor: pointer; border-left: 4px solid var(--sc); box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.card:hover { border-color: var(--primary); border-left-color: var(--sc); }
.card.dragging { opacity: .4; }
.card .card-title { font-weight: 500; margin-bottom: 8px; word-break: break-word; }
.card.is-done .card-title { text-decoration: line-through; color: var(--muted); }
.card .card-foot { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.card .meta { display: flex; gap: 6px; align-items: center; }
.col .add-card { border: 1px dashed var(--border); background: transparent; color: var(--muted); border-radius: 8px; padding: 7px; cursor: pointer; }
.col .add-card:hover { color: var(--primary); border-color: var(--primary); }

/* ---------- Popover ---------- */
.popover {
  position: fixed; z-index: 50; background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: var(--shadow); padding: 6px; min-width: 160px;
}
.popover button { display: flex; align-items: center; gap: 8px; width: 100%; border: 0; background: none; text-align: left; padding: 7px 10px; border-radius: 6px; cursor: pointer; }
.popover button:hover { background: var(--surface-2); }
.popover .swatch { width: 12px; height: 12px; border-radius: 3px; }
.popover hr { border: 0; border-top: 1px solid var(--border); margin: 4px 0; }
.popover .who { padding: 8px 10px; font-size: 12px; color: var(--muted); }

/* ---------- Modale ---------- */
.overlay { position: fixed; inset: 0; background: rgba(15, 18, 25, .45); z-index: 40; display: grid; place-items: center; padding: 16px; }
.modal {
  width: 100%; max-width: 560px; max-height: calc(100vh - 32px); overflow: auto;
  background: var(--surface); border-radius: 14px; box-shadow: var(--shadow); border: 1px solid var(--border);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 16px; }
.modal-body { padding: 18px 20px 4px; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 20px 18px; flex-wrap: wrap; }
.modal-foot .left { margin-right: auto; display: flex; gap: 8px; }

.people-picker { display: flex; flex-wrap: wrap; gap: 6px; }
.person-toggle {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 4px 4px;
  border: 1px solid var(--border); border-radius: 20px; background: var(--surface); cursor: pointer;
}
.person-toggle.on { border-color: var(--primary); background: var(--primary-soft); }
.hint { font-size: 12px; color: var(--muted); margin-top: 2px; }

.member-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.member-row:last-child { border-bottom: 0; }
.member-row .info { flex: 1; min-width: 0; }
.member-row .info div:last-child { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; }
.role-badge { font-size: 11px; padding: 2px 7px; border-radius: 10px; background: var(--surface-2); color: var(--muted); }
.colors { display: flex; gap: 6px; flex-wrap: wrap; }
.color-dot { width: 24px; height: 24px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; }
.color-dot.on { border-color: var(--text); }
.section-title { font-size: 13px; font-weight: 700; margin: 18px 0 10px; }

/* ---------- Toast ---------- */
#toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: #1f2430; color: #fff; padding: 10px 16px; border-radius: 8px; opacity: 0;
  transition: .2s; pointer-events: none; z-index: 60; max-width: calc(100% - 32px);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.err { background: var(--danger); }

/* ---------- Mobile ---------- */
@media (max-width: 760px) {
  .topbar { padding: 10px 16px; gap: 8px; }
  .week-label { min-width: 0; font-size: 13px; }
  .toolbar, main { padding-left: 16px; padding-right: 16px; }
  .tr { grid-template-columns: 1fr 96px 36px; }
  .tr > .col-people, .tr > .col-day, .tr > .col-prio { display: none; }
  .progress { display: none; }
  .row { flex-direction: column; gap: 0; }
  .hide-sm { display: none; }
}
