* { box-sizing: border-box; }

body {
  font-family: system-ui, -apple-system, sans-serif;
  max-width: 900px;
  margin: 0 auto;
  padding: 24px;
  background: #f7f8fa;
  color: #1a1a1a;
}

header { margin-bottom: 24px; }
h1 { margin-bottom: 4px; }
.subtitle { color: #666; margin-top: 0; }

.bloc-contexte {
  display: flex;
  gap: 16px;
  background: white;
  padding: 16px;
  border-radius: 8px;
  margin-bottom: 20px;
}
.bloc-contexte label {
  display: flex;
  flex-direction: column;
  flex: 1;
  font-size: 0.9em;
  font-weight: 600;
}
.bloc-contexte input, .bloc-contexte select {
  margin-top: 4px;
  padding: 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 1em;
}

.bloc-phase {
  background: white;
  padding: 16px 20px;
  border-radius: 8px;
  margin-bottom: 16px;
}
.bloc-phase h2 {
  font-size: 1.1em;
  border-bottom: 2px solid #0066cc;
  padding-bottom: 8px;
  margin-top: 0;
}

.groupe-variante {
  border-left: 3px solid #0066cc;
  padding-left: 12px;
  margin-bottom: 8px;
}

.ligne-tache {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid #eee;
  cursor: pointer;
}
.ligne-tache:last-child { border-bottom: none; }

.nom-tache { flex: 1; }

.jours {
  font-size: 0.85em;
  color: #666;
  min-width: 130px;
  text-align: right;
}

.tooltip-wrap {
  position: relative;
  display: inline-flex;
}
.tooltip-icon {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ccc;
  color: white;
  font-size: 0.75em;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: help;
}
.tooltip-content {
  display: none;
  position: absolute;
  left: 20px;
  top: -8px;
  width: 280px;
  background: #1a1a1a;
  color: white;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 0.85em;
  line-height: 1.4;
  z-index: 10;
}
.tooltip-wrap:hover .tooltip-content { display: block; }

.btn-submit {
  display: inline-block;
  background: #0066cc;
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 6px;
  font-size: 1em;
  cursor: pointer;
  text-decoration: none;
  margin-top: 8px;
}
.btn-submit:hover { background: #0052a3; }

.bloc-actions {
  display: flex;
  gap: 12px;
  margin-top: 8px;
}
.btn-excel { background: #1e7e34; }
.btn-excel:hover { background: #17652a; }
.btn-docx { background: #2b579a; margin-left: 8px; }
.btn-docx:hover { background: #204170; }

.table-recap {
  width: 100%;
  border-collapse: collapse;
  background: white;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 16px;
}
.table-recap th, .table-recap td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid #eee;
}
.table-recap th { background: #0066cc; color: white; }
.table-recap td:nth-child(2), .table-recap td:nth-child(3) { text-align: right; }
.table-recap tfoot td { background: #f0f4f8; font-weight: bold; }

.note {
  background: #fff8e1;
  border-left: 4px solid #f5a623;
  padding: 10px 14px;
  font-size: 0.9em;
  border-radius: 4px;
}

/* ---- Header avec navigation ---- */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}
header nav {
  display: flex;
  align-items: center;
  gap: 14px;
  white-space: nowrap;
}
.lien-nav {
  color: #0066cc;
  text-decoration: none;
  font-size: 0.9em;
  font-weight: 600;
}
.lien-nav:hover { text-decoration: underline; }

/* ---- Page de connexion ---- */
.page-login {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}
.bloc-login {
  background: white;
  padding: 32px;
  border-radius: 8px;
  width: 320px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}
.bloc-login h1 { margin-top: 0; }
.bloc-login form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 16px;
}
.bloc-login label {
  display: flex;
  flex-direction: column;
  font-weight: 600;
  font-size: 0.9em;
}
.bloc-login input {
  margin-top: 6px;
  padding: 10px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 1.1em;
  text-transform: lowercase;
}
.erreur {
  background: #fdecea;
  color: #a12622;
  padding: 10px 14px;
  border-radius: 4px;
  font-size: 0.9em;
}
.aide-champ {
  margin-top: -8px;
  font-size: 0.85em;
  color: #666;
}

/* ---- Header admin ---- */
.header-admin {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
}
.header-admin nav {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ---- Cartes stats du dashboard admin ---- */
.bloc-stats {
  display: flex;
  gap: 16px;
  margin-bottom: 24px;
}
.carte-stat {
  background: white;
  border-radius: 8px;
  padding: 20px;
  flex: 1;
  text-align: center;
}
.carte-stat .chiffre {
  display: block;
  font-size: 2em;
  font-weight: bold;
  color: #0066cc;
}
.carte-stat .libelle {
  font-size: 0.85em;
  color: #666;
}

.bloc-liens-admin {
  display: flex;
  gap: 16px;
}
.carte-lien {
  background: white;
  border-radius: 8px;
  padding: 20px;
  flex: 1;
  text-decoration: none;
  color: inherit;
  border: 1px solid #e0e0e0;
  transition: border-color 0.15s;
}
.carte-lien:hover { border-color: #0066cc; }
.carte-lien h2 { margin-top: 0; font-size: 1.1em; color: #0066cc; }
.carte-lien p { margin-bottom: 0; font-size: 0.9em; color: #555; }

/* ---- Table admin (tâches / phases) ---- */
.table-admin {
  width: 100%;
  border-collapse: collapse;
  background: white;
  border-radius: 8px;
  overflow: hidden;
}
.table-admin th, .table-admin td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid #eee;
  font-size: 0.9em;
}
.table-admin th { background: #0066cc; color: white; }
.ligne-inactive { opacity: 0.5; }

.badge-toggle {
  border: none;
  border-radius: 12px;
  padding: 4px 10px;
  font-size: 0.75em;
  font-weight: 600;
  cursor: pointer;
}
.badge-actif { background: #d4edda; color: #1e7e34; }
.badge-inactif { background: #e2e3e5; color: #555; }

.tag-statut {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.8em;
}
.tag-obligatoire { background: #cfe2ff; color: #084298; }
.tag-option { background: #fff3cd; color: #664d03; }
.tag-variante { background: #e2d9f3; color: #4b2e83; }

.cell-actions { display: flex; gap: 10px; align-items: center; }
.form-inline { display: inline; margin: 0; }
.lien-danger {
  background: none;
  border: none;
  color: #c0392b;
  cursor: pointer;
  font-size: 0.85em;
  text-decoration: underline;
  padding: 0;
}

/* ---- Formulaire admin (création/édition tâche) ---- */
.form-admin {
  background: white;
  padding: 20px;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 640px;
}
.form-admin label {
  display: flex;
  flex-direction: column;
  font-weight: 600;
  font-size: 0.9em;
  gap: 4px;
}
.form-admin input, .form-admin select, .form-admin textarea {
  padding: 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 1em;
  font-family: inherit;
}
.form-row { display: flex; gap: 14px; }
.form-row label { flex: 1; }
.label-checkbox { flex-direction: row !important; align-items: center; gap: 8px !important; }

.bloc-form-rapide {
  background: white;
  border-radius: 8px;
  padding: 20px;
  margin-top: 20px;
}
.form-inline-fields {
  display: flex;
  gap: 14px;
  align-items: flex-end;
  margin-top: 12px;
}
.form-inline-fields label {
  display: flex;
  flex-direction: column;
  font-size: 0.9em;
  font-weight: 600;
}
.form-inline-fields input {
  margin-top: 4px;
  padding: 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
}

/* ---- Historique des devis ---- */
.badge-trigramme {
  display: inline-block;
  background: #0066cc;
  color: white;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.85em;
  font-weight: 600;
  text-transform: uppercase;
}
.table-historique td { vertical-align: middle; }
.cell-phase {
  color: #666;
  font-size: 0.85em;
}
