:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --green: #d1fae5;
  --green-text: #065f46;
  --amber: #fef3c7;
  --amber-text: #92400e;
  --red: #fee2e2;
  --red-text: #991b1b;
}

[v-cloak] { display: none; }

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

h1 { font-size: 1.25rem; margin: 0; }
h2 { font-size: 1.05rem; margin: 0 0 0.75rem; }
h3 { font-size: 0.95rem; margin: 1.5rem 0 0.5rem; }

.muted { color: var(--muted); }
.small { font-size: 0.78rem; }
.right { text-align: right; }
.error { color: var(--red-text); font-size: 0.85rem; }

/* ---------- Connexion ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card {
  background: var(--panel);
  padding: 2rem;
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
  width: 320px;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.login-card label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.85rem; }

/* ---------- En-tête ---------- */
header {
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.6rem 1.25rem;
  position: sticky;
  top: 0;
  z-index: 10;
}
header nav { display: flex; gap: 0.25rem; flex: 1; }
header nav button {
  background: none;
  border: none;
  padding: 0.5rem 0.9rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--muted);
}
header nav button.active { background: #eff6ff; color: var(--primary); font-weight: 600; }
.header-right { display: flex; align-items: center; gap: 0.75rem; font-size: 0.85rem; }

/* ---------- Panneaux ---------- */
main { padding: 1.25rem; max-width: 1400px; margin: 0 auto; }
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

/* ---------- Formulaires ---------- */
input, button, select {
  font: inherit;
  padding: 0.45rem 0.7rem;
  border-radius: 8px;
  border: 1px solid var(--border);
}
input:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: transparent; }
button {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  cursor: pointer;
}
button:hover { background: var(--primary-dark); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.ghost {
  background: transparent;
  color: var(--primary);
  border-color: var(--border);
}
button.ghost:hover { background: #eff6ff; }
button.danger { color: var(--red-text); }
button.danger:hover { background: var(--red); }
.inline-form { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.checkbox { font-size: 0.85rem; display: inline-flex; gap: 0.4rem; align-items: center; margin-bottom: 0.5rem; }

/* ---------- Tableaux ---------- */
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th, td { text-align: left; padding: 0.5rem 0.65rem; border-bottom: 1px solid var(--border); }
thead th { color: var(--muted); font-weight: 600; font-size: 0.8rem; }
tr.archived td { color: var(--muted); }

/* ---------- Grille planning ---------- */
.range-bar { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 0.5rem; }
.range-controls { display: flex; gap: 0.35rem; }
.grid-scroll { overflow-x: auto; margin-top: 0.75rem; }
table.grid th, table.grid td { border: 1px solid var(--border); min-width: 86px; }
table.grid th.sticky {
  position: sticky;
  left: 0;
  background: var(--panel);
  min-width: 140px;
  z-index: 2;
}
table.grid thead th.today { background: #eff6ff; color: var(--primary); }
.cell { cursor: pointer; vertical-align: top; transition: background 0.1s; position: relative; }
.cell:hover { outline: 2px solid var(--primary); outline-offset: -2px; }
.cell.copied { outline: 2px dashed var(--primary); outline-offset: -2px; }
.cell.selected-cell { box-shadow: inset 0 0 0 2px var(--primary); background-color: #eff6ff; }
.cell-actions {
  position: absolute;
  top: 2px;
  right: 2px;
  display: none;
  gap: 2px;
  z-index: 3;
}
.cell:hover .cell-actions { display: inline-flex; }
.cell-btn {
  padding: 0 4px;
  font-size: 0.72rem;
  line-height: 1.4;
  background: var(--panel);
  color: var(--primary);
  border: 1px solid var(--border);
  border-radius: 4px;
}
.cell-btn:hover { background: #eff6ff; }
/* ---------- Répartition mensuelle par personne ---------- */
.month-breakdown { display: flex; gap: 1.75rem; flex-wrap: wrap; margin-bottom: 0.5rem; }
.month-col { flex: 1 1 380px; min-width: 320px; }
.month-title { margin: 0.4rem 0 0.6rem; text-transform: capitalize; font-size: 0.95rem; }
.breakdown-table { width: 100%; border-collapse: collapse; }
.breakdown-table th.breakdown-name {
  text-align: left; padding: 0.55rem 0.75rem 0.55rem 0; white-space: nowrap;
  vertical-align: top; width: 1%; font-weight: 600; color: var(--text); font-size: 0.85rem;
}
.breakdown-table td { padding: 0.55rem 0; vertical-align: top; }
.repartition-bar {
  display: flex; height: 20px; border-radius: 5px; overflow: hidden; background: var(--border);
}
.repartition-seg {
  display: flex; align-items: center; justify-content: center; color: #fff;
  font-size: 0.7rem; font-weight: 600; overflow: hidden; white-space: nowrap; min-width: 0;
}
.repartition-legend {
  display: flex; flex-wrap: wrap; gap: 0.25rem 0.85rem; margin-top: 0.35rem;
  font-size: 0.78rem; color: var(--muted);
}
.legend-item { display: inline-flex; align-items: center; gap: 0.35rem; }
.legend-dot { width: 9px; height: 9px; border-radius: 2px; display: inline-block; flex: none; }

.clipboard-banner {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
/* Charge : sous-chargé = sans couleur, correctement chargé = vert, surchargé = rouge */
.cell.full, td.full { background: var(--green); color: var(--green-text); }
.cell.over, td.over { background: var(--red); color: var(--red-text); }
td.empty { color: var(--muted); }
.chips { display: flex; flex-direction: column; gap: 2px; margin-top: 3px; }
.chip {
  font-size: 0.72rem;
  background: rgba(255, 255, 255, 0.65);
  border-radius: 4px;
  padding: 1px 5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 130px;
}
.total-row th, .total-row td { border-top: 2px solid var(--text); }

/* ---------- Bascule heures / jours ---------- */
.unit-toggle { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.unit-toggle button { border: none; border-radius: 0; }
.unit-toggle button.active { background: var(--primary); color: #fff; }
.self-center { align-self: center; }
.editor-header { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; }
.editor-header p { margin: 0; }
.editor-input { display: inline-flex; align-items: center; gap: 0.35rem; }

/* ---------- Formulaire empilé (modale) ---------- */
.stacked-form { display: flex; flex-direction: column; gap: 0.75rem; }
.stacked-form label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.85rem; }
.stacked-form .modal-actions { margin-top: 0.5rem; }
button.icon { padding: 0.1rem 0.45rem; line-height: 1; font-size: 0.7rem; }
.order-cell { white-space: nowrap; }
.order-cell .icon + .icon { margin-left: 2px; }
.drag-cell { cursor: grab; color: var(--muted); user-select: none; text-align: center; width: 1.5rem; }
.drag-cell:active { cursor: grabbing; }
tr.dragging { opacity: 0.4; }
tr.drag-over td { border-top: 2px solid var(--primary); }

/* ---------- Jalons ---------- */
.milestone-row td { background: #fafbfc; font-size: 0.84rem; }
.req-planned { font-weight: 600; }
.req-plus { color: var(--amber-text); font-weight: 700; margin: 0 0.25rem; }
.req-carry { color: var(--amber-text); font-weight: 600; }
.indent { padding-left: 1.6rem; color: var(--muted); }
.milestone-form { margin-top: 1rem; }

/* ---------- Barres et badges ---------- */
.bar { background: var(--border); border-radius: 6px; height: 10px; min-width: 110px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 6px; }
.bar-fill.ok { background: #10b981; }
.bar-fill.warn { background: #f59e0b; }
.badge { padding: 0.2rem 0.55rem; border-radius: 999px; font-size: 0.78rem; font-weight: 600; }
.badge.ok { background: var(--green); color: var(--green-text); }
.badge.warn { background: var(--amber); color: var(--amber-text); }
.badge.danger { background: var(--red); color: var(--red-text); }
.badge.neutral { background: #e0e7ff; color: #3730a3; }

/* ---------- Notifications ---------- */
.flash {
  position: fixed;
  top: 4rem;
  right: 1.25rem;
  z-index: 50;
  padding: 0.7rem 1.1rem;
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  cursor: pointer;
  font-size: 0.88rem;
  max-width: 420px;
}
.flash.success { background: var(--green); color: var(--green-text); }
.flash.error { background: var(--red); color: var(--red-text); }

/* ---------- Modale ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 40;
}
.modal {
  background: var(--panel);
  border-radius: 12px;
  padding: 1.5rem;
  width: 460px;
  max-width: calc(100vw - 2rem);
  max-height: 85vh;
  overflow-y: auto;
}
.modal h3 { margin-top: 0; }
.editor-rows { display: flex; flex-direction: column; gap: 0.5rem; margin: 1rem 0; }
.editor-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.88rem;
}
.editor-row input { width: 90px; text-align: right; }
.editor-row input.invalid { border-color: #dc2626; outline-color: #dc2626; }
.editor-row .preview { min-width: 64px; text-align: left; }
.editor-row.disabled { opacity: 0.55; }

/* ---------- Congés ---------- */
.vacation-box {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  margin-top: 0.75rem;
}
.vacation-day { display: inline-flex; align-items: center; gap: 0.25rem; font-size: 0.82rem; cursor: pointer; }
.vacation-week { font-weight: 600; }
.vacation-sep { width: 1px; align-self: stretch; background: #bae6fd; }
.vacation-badge {
  display: inline-block;
  font-size: 0.72rem;
  background: #e0f2fe;
  color: #075985;
  border-radius: 4px;
  padding: 1px 5px;
  margin-bottom: 2px;
}
.cell.vacation { background: #f0f9ff; }
.modal-actions { display: flex; justify-content: flex-end; gap: 0.5rem; }
