:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1c2430;
  --muted: #6b7684;
  --primary: #1a5fb4;
  --danger: #c01c28;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.container { max-width: 760px; margin: 0 auto; padding: 16px; }

/* Barre supérieure */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--card); padding: 10px 16px;
  border-bottom: 1px solid #e2e5ea;
  position: sticky; top: 0; z-index: 10;
}
.topbar .brand { font-weight: 700; color: var(--primary); text-decoration: none; }
.topbar nav { display: flex; gap: 12px; align-items: center; }
.topbar nav a { color: var(--text); text-decoration: none; }
.topbar .user { color: var(--muted); }

/* Titres / mise en page */
h1 { font-size: 1.35rem; margin: 0.4em 0; }
h2 { font-size: 1.1rem; margin: 1.2em 0 0.5em; }
.page-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }

/* Cartes connexion / formulaires */
.auth-card, .form-card {
  background: var(--card); border-radius: var(--radius);
  padding: 20px; margin-top: 20px;
  border: 1px solid #e2e5ea;
}
.auth-card { max-width: 400px; margin: 10vh auto; }

/* Formulaires */
label { display: block; margin: 12px 0; font-weight: 600; font-size: 0.9rem; }
input, select, textarea {
  display: block; width: 100%; margin-top: 4px;
  padding: 10px; font-size: 1rem;
  border: 1px solid #c8cdd4; border-radius: 8px;
  background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); border-color: var(--primary); }
fieldset { border: 1px solid #e2e5ea; border-radius: var(--radius); margin: 12px 0; padding: 4px 12px 12px; }
legend { font-weight: 600; font-size: 0.9rem; padding: 0 6px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }

/* Boutons */
.btn {
  display: inline-block; padding: 10px 16px; font-size: 1rem;
  border: 1px solid #c8cdd4; border-radius: 8px;
  background: #fff; color: var(--text); text-decoration: none;
  cursor: pointer; text-align: center;
}
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-sm { padding: 4px 10px; font-size: 0.9rem; }
.btn-block { width: 100%; }
.form-actions { display: flex; gap: 10px; margin-top: 16px; }
.inline { display: inline; }

/* Alertes et textes */
.alert { background: #fdecea; color: var(--danger); padding: 10px; border-radius: 8px; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; }
.wrap { word-break: break-all; }

/* QR code */
.qr { text-align: center; margin: 12px 0; }
.qr img { width: 200px; max-width: 100%; border-radius: 8px; }
.steps { padding-left: 20px; }

/* Liste de projets en cartes */
.cards { list-style: none; padding: 0; display: grid; gap: 10px; }
.card { background: var(--card); border: 1px solid #e2e5ea; border-radius: var(--radius); }
.card.card-ok { background: #e8f7ee; border-color: #b9e4c9; }
.card.card-due { background: #fdf1e0; border-color: #f2d3a4; }
.card a { display: block; padding: 14px; color: inherit; text-decoration: none; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.card-meta { display: flex; gap: 10px; color: var(--muted); font-size: 0.85rem; margin-top: 4px; flex-wrap: wrap; }

/* Badges de statut */
.badge { padding: 3px 10px; border-radius: 999px; font-size: 0.78rem; font-weight: 600; white-space: nowrap; }
.badge-en_etude { background: #e5e7eb; color: #374151; }
.badge-conception { background: #dbeafe; color: #1d4ed8; }
.badge-en_fab { background: #fef3c7; color: #b45309; }
.badge-livre { background: #d1fae5; color: #047857; }
.badge-archive { background: #fee2e2; color: #b91c1c; }

/* Détails projet */
.details { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; background: var(--card); border: 1px solid #e2e5ea; border-radius: var(--radius); padding: 14px 16px; }
.details dt { font-weight: 600; color: var(--muted); }
.details dd { margin: 0; }

/* Tableau devis */
.table { width: 100%; border-collapse: collapse; background: var(--card); border-radius: var(--radius); overflow: hidden; margin-top: 12px; }
.table th, .table td { padding: 10px; text-align: left; border-bottom: 1px solid #e2e5ea; font-size: 0.95rem; }
.table th { background: #eef1f4; }

/* Onglets de filtre des projets (téléphone et PC) */
.tabs { display: flex; gap: 6px; margin: 4px 0 14px; }
.tab {
  flex: 1; text-align: center; padding: 10px 8px; font-size: 0.95rem;
  background: var(--card); border: 1px solid #e2e5ea; border-radius: 8px;
  color: var(--text); text-decoration: none;
}
.tab-active { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }

/* Cartes de synthèse (soldes) */
.summary-cards {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 12px 0;
}
.summary-card {
  background: var(--card); border: 1px solid #e2e5ea; border-radius: var(--radius);
  padding: 14px; display: flex; flex-direction: column; gap: 4px;
}
.summary-card strong { font-size: 1.25rem; }
.summary-label { color: var(--muted); font-size: 0.82rem; }
.summary-danger strong { color: var(--danger); }
.summary-ok strong { color: #047857; }

/* Petit écran : détails en une seule colonne */
@media (max-width: 480px) {
  .grid-2 { grid-template-columns: 1fr; }
  .details { grid-template-columns: 1fr; gap: 2px; }
  .details dt { margin-top: 8px; }
  .table th:nth-child(3), .table td:nth-child(3) { display: none; }
  .summary-cards { grid-template-columns: 1fr; }
}

/* Case à cocher sur sa ligne */
label.checkbox { display: flex; align-items: center; gap: 8px; font-weight: 400; }
label.checkbox input { width: auto; margin: 0; }

/* Encadré « Remarque : à noter » */
.remarks-box {
  background: var(--card); border: 1px solid #e2e5ea; border-left: 4px solid var(--primary);
  border-radius: var(--radius); padding: 12px 14px; margin: 12px 0;
}
.remarks-box p { margin: 6px 0 0; white-space: pre-wrap; }

/* Titre de projet dans la liste des versements client */
.project-payments-title { font-size: 1rem; margin: 14px 0 4px; }
.project-payments-title a { color: var(--primary); text-decoration: none; }

/* Champ remarque inline dans le tableau projets de la fiche client */
.remarks-form { display: flex; gap: 4px; align-items: center; }
.remarks-form input[type="text"] { width: 140px; margin: 0; padding: 4px 8px; font-size: 0.85rem; }

/* Total coût de production */
.summary-total { max-width: 320px; margin-top: 12px; }

/* Titre de section « Trajet équipe » dans le tableau des coûts */
tr.trip-header :is(td, th) {
  background: #dde7f3; color: var(--primary); font-weight: 700;
  letter-spacing: 0.4px; padding: 8px 10px;
}

/* Aide repliable du calcul de trajet */
details.calc-help {
  background: #f0f4f9; border: 1px solid #d7e0ea; border-radius: var(--radius);
  padding: 10px 14px; margin: 12px 0; font-size: 0.9rem;
}
details.calc-help summary { cursor: pointer; font-weight: 600; color: var(--primary); }
details.calc-help p { margin: 8px 0; }

/* Calendrier du planning */
.cal-grid td { height: 64px; width: 14.28%; vertical-align: top; padding: 4px; }
.cal-grid td.cal-empty { background: #f7f8fa; }
.cal-grid td.cal-today { outline: 2px solid var(--primary); outline-offset: -2px; }
.cal-day { font-weight: 700; font-size: 0.8rem; color: var(--muted); display: block; }
.cal-task {
  display: block; background: #dbeafe; color: #1d4ed8; border-radius: 4px;
  font-size: 0.72rem; padding: 1px 4px; margin-top: 2px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
.cal-task-done { background: #e5e7eb; color: #6b7280; text-decoration: line-through; }
.task-done { text-decoration: line-through; color: var(--muted); }

/* Page Accueil : grandes cartes d'accès */
.home-cards {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 10px 0 20px;
}
.home-card {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  background: var(--card); border: 1px solid #e2e5ea; border-radius: var(--radius);
  padding: 26px 16px; text-decoration: none; color: var(--text); font-size: 1.15rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.home-card:hover { border-color: var(--primary); }
.home-icon { font-size: 2.2rem; }

/* Onglets : bleu au passage de la souris */
.tab:hover {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* Bouton Modifier (orange) + légende */
.btn-warning {
  background: #e8890c;
  border-color: #e8890c;
  color: #fff;
}
.btn-warning:hover {
  background: #c97408;
  border-color: #c97408;
  color: #fff;
}
.legend-warning { color: #e8890c; }

/* Paire de lignes modifiées : ancienne annulée (orange) + nouvelle corrigée (vert clair) */
tr.pointage-modifie td {
  background: #fdebd7;
}
tr.pointage-annule td {
  color: #8a5a1a;
}
tr.pointage-nouveau td {
  background: #e8f7ee;
}
.badge-annule {
  background: #f5c98a; color: #8a5a1a; padding: 2px 8px;
  border-radius: 999px; font-size: 0.75rem; font-weight: 700;
}

/* Sous-ligne motif : petite, sur toute la largeur, sans élargir la ligne */
tr.pointage-motif td {
  padding: 0 10px 6px;
  border-bottom: 1px solid #e2e5ea;
}

/* Bouton Modifier recentré et compact */
.pointage-actions {
  text-align: center;
  white-space: nowrap;
  width: 1%;
}
.pointage-actions .btn {
  padding: 4px 8px;
  font-size: 0.8rem;
}
