:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #1f2733;
  --muted: #6b7480;
  --line: #e4e7ec;
  --brand: #2f6b4f;          /* vert EDEN */
  --brand-dark: #234f3b;

  /* Phases du planning — couleurs vives */
  --prep: #2f6bed;          /* bleu */
  --prep-2: #4f8bff;
  --anim: #f5921b;          /* orange */
  --anim-2: #ffb04d;
  --analyse: #19a558;       /* vert */
  --analyse-2: #2ecb73;

  /* Calendrier */
  --ferie: #c0392b;
  --conge: #8e8e93;
  --vacances: #b9a3d6;
  --weekend: #eef0f3;
  --today: #c0392b;

  /* Statuts CA */
  --paye: #2f8f4e;
  --facture: #2d6cdf;
  --afacturer: #d98324;

  --radius: 8px;
  --shadow: 0 1px 3px rgba(20,30,50,.08), 0 6px 24px rgba(20,30,50,.06);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.45;
}

/* ── Barre de navigation ─────────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; gap: 18px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  padding: 0 20px; height: 56px;
  position: sticky; top: 0; z-index: 40;
}
.brand { display: flex; align-items: center; }
.brand img { height: 30px; width: auto; display: block; }
.nav { display: flex; gap: 4px; }
.nav a {
  text-decoration: none; color: var(--muted); padding: 7px 14px;
  border-radius: 6px; font-weight: 600;
}
.nav a.active { color: var(--brand); background: #eaf3ee; }
.nav a:hover { background: #f0f2f5; }
.topbar .spacer { flex: 1; }
.userbox { display: flex; align-items: center; gap: 10px; color: var(--muted); }
.userbox form { margin: 0; }

button, .btn {
  font: inherit; cursor: pointer; border: 1px solid var(--line);
  background: var(--panel); color: var(--ink);
  padding: 7px 13px; border-radius: 6px; font-weight: 600;
}
button:hover, .btn:hover { background: #f0f2f5; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-danger { color: var(--ferie); border-color: #e7c3bf; background: #fdf2f1; }
.btn-sm { padding: 4px 9px; font-size: 12.5px; }

/* ── Mise en page page ───────────────────────────────────────────── */
.page { padding: 18px 20px; }
.page-head { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.page-head h1 { font-size: 18px; margin: 0; }
.page-head .spacer { flex: 1; }
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.toolbar-select { font: inherit; padding: 6px 9px; border: 1px solid var(--line); border-radius: 6px; background: #fff; font-weight: 600; }

/* ── Légende ─────────────────────────────────────────────────────── */
.legend { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; color: var(--muted); font-size: 12.5px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 14px; height: 14px; border-radius: 3px; display: inline-block; }

/* ── Gantt ───────────────────────────────────────────────────────── */
.gantt-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.gantt-scroll { overflow: auto; max-height: calc(100vh - 200px); }
.gantt-inner { position: relative; width: max-content; min-width: 100%; }

.g-header { position: sticky; top: 0; z-index: 20; background: var(--panel); }
.g-months, .g-days { display: flex; }
.g-corner {
  position: sticky; left: 0; z-index: 22; background: var(--panel);
  border-right: 1px solid var(--line); border-bottom: 1px solid var(--line);
  flex: 0 0 auto; display: flex; align-items: flex-end; padding: 4px 10px;
  font-weight: 700; color: var(--muted); font-size: 12px;
}
.g-month { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line);
  text-align: center; font-weight: 700; font-size: 12px; padding: 5px 0; color: #3a4452;
  text-transform: uppercase; letter-spacing: .4px; flex: 0 0 auto; }
.g-day { border-right: 1px solid #f0f1f4; border-bottom: 1px solid var(--line);
  text-align: center; font-size: 10px; color: var(--muted); padding: 3px 0; flex: 0 0 auto; }
.g-day.we { background: var(--weekend); }
.g-day .dow { display: block; font-size: 8.5px; opacity: .7; }

.g-row { display: flex; position: relative; border-bottom: 1px solid #f0f1f4; }
.g-row:hover .g-label { background: #f4f7f5; }
.g-label {
  position: sticky; left: 0; z-index: 15; background: var(--panel);
  border-right: 1px solid var(--line); flex: 0 0 auto;
  padding: 6px 10px; cursor: pointer; overflow: hidden;
}
.g-label .cli { font-weight: 700; font-size: 12px; }
.g-label .prj { color: var(--muted); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g-label .dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; margin-right: 5px; }
.g-track { position: relative; flex: 0 0 auto; height: 42px; }

.bar { position: absolute; top: 8px; height: 26px; border-radius: 6px; cursor: pointer;
  font-size: 11px; font-weight: 700; color: #fff; white-space: nowrap; overflow: hidden;
  display: flex; align-items: center; padding: 0 7px; letter-spacing: .2px;
  box-shadow: 0 1px 2px rgba(20,30,50,.18); text-shadow: 0 1px 1px rgba(0,0,0,.18); }
.bar.prep { background: linear-gradient(180deg, var(--prep-2), var(--prep)); }
.bar.anim { background: linear-gradient(180deg, var(--anim-2), var(--anim)); }
.bar.analyse { background: linear-gradient(180deg, var(--analyse-2), var(--analyse)); }
.bar:hover { filter: brightness(1.06); box-shadow: 0 3px 8px rgba(20,30,50,.28); z-index: 7; }

.marker { position: absolute; top: 4px; z-index: 6; transform: translateX(-50%);
  font-weight: 800; color: var(--ferie); font-size: 15px; cursor: pointer; line-height: 30px; }
.marker.pre-rendu { color: var(--anim); }
.marker.presentation { color: var(--prep); }

/* couche de fond : weekends, fériés, ligne du jour */
.g-bg { position: absolute; top: 0; bottom: 0; z-index: 1; pointer-events: none; }
.bg-we { position: absolute; top: 0; bottom: 0; background: var(--weekend); }
.bg-ferie { position: absolute; top: 0; bottom: 0; background: rgba(192,57,43,.10); }
.bg-today { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--today); z-index: 3; }

/* lignes masquées (affichées seulement si on coche "Afficher masquées") */
.g-row.is-masked { opacity: .5; }
.g-row.is-masked .g-label .cli::after { content: " · masqué"; color: var(--muted); font-weight: 500; font-size: 10px; }

/* lignes spéciales (congés / vacances) */
.g-row.special .g-label .cli { font-weight: 600; color: #4a5360; }
.span-conge { position: absolute; top: 9px; height: 18px; border-radius: 4px; background: var(--conge); opacity: .55;
  font-size: 10px; color: #fff; display: flex; align-items: center; padding: 0 6px; white-space: nowrap; }
.span-vacances { position: absolute; top: 9px; height: 18px; border-radius: 4px; background: var(--vacances); opacity: .6;
  font-size: 10px; color: #43345e; display: flex; align-items: center; padding: 0 6px; white-space: nowrap; }

/* ── Tableau CA ──────────────────────────────────────────────────── */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
table.ca { width: 100%; border-collapse: collapse; }
table.ca th, table.ca td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line); }
table.ca th { font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); background: #fafbfc; position: sticky; top: 56px; }
table.ca td.num, table.ca th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.ca tr:hover td { background: #f8faf9; cursor: pointer; }
table.ca tfoot td { font-weight: 800; border-top: 2px solid var(--line); background: #fafbfc; }

.tag { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 700; }
.tag.EDEN { background: #e7efe9; color: #2f6b4f; }
.tag.POLLEN { background: #f3e9d6; color: #9a6a16; }
.tag.\(POLLEN\ LICENCE\), .tag.LICENCE { background: #f0e3f3; color: #7b3f8c; }
.status { display: inline-block; padding: 2px 9px; border-radius: 6px; font-size: 11.5px; font-weight: 700; }
.status.paye { background: #e3f3e8; color: var(--paye); }
.status.facture { background: #e6effd; color: var(--facture); }
.status.afacturer { background: #fbeeda; color: var(--afacturer); }

.kpis { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; box-shadow: var(--shadow); min-width: 150px; }
.kpi .v { font-size: 22px; font-weight: 800; }
.kpi .l { color: var(--muted); font-size: 12px; }

/* ── Modale ──────────────────────────────────────────────────────── */
.modal-backdrop { position: fixed; inset: 0; background: rgba(20,28,40,.45); z-index: 100;
  display: none; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow: auto; }
.modal-backdrop.open { display: flex; }
.modal { background: var(--panel); border-radius: 12px; width: 100%; max-width: 640px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal header { display: flex; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal header h2 { margin: 0; font-size: 16px; }
.modal header .spacer { flex: 1; }
.modal .body { padding: 18px 20px; }
.modal footer { display: flex; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); }
.modal footer .spacer { flex: 1; }

.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; font-weight: 700; color: #46505d; margin-bottom: 4px; }
.field input, .field select, .field textarea {
  width: 100%; font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.field textarea { resize: vertical; min-height: 56px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.section-title { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted);
  font-weight: 800; margin: 16px 0 8px; border-top: 1px solid var(--line); padding-top: 12px; }
.check-line { display: flex; align-items: center; gap: 8px; font-weight: 600; color: #46505d; cursor: pointer; padding: 4px 0; }
.markers-list { display: flex; flex-direction: column; gap: 6px; }
.marker-row { display: grid; grid-template-columns: 140px 1fr auto; gap: 8px; align-items: center; }
.hint { color: var(--muted); font-size: 12px; }
.error-box { background: #fdf2f1; color: var(--ferie); border: 1px solid #f0c8c3; border-radius: 6px; padding: 8px 12px; margin-bottom: 12px; }

/* ── Login ───────────────────────────────────────────────────────── */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg,#eef3f0,#f6f7f9); }
.login-card { background: var(--panel); border-radius: 14px; box-shadow: var(--shadow); padding: 32px; width: 340px; }
.login-logo { height: 46px; width: auto; display: block; margin: 0 auto 14px; }
.login-card p { color: var(--muted); margin: 0 0 20px; font-size: 13px; text-align: center; text-transform: uppercase; letter-spacing: 1px; }
.login-card .field { margin-bottom: 14px; }
.login-card button { width: 100%; }
