/*
 * Système graphique repris à l'identique de l'appli de référence du client
 * (palette + typographie + composants) : fond crème, titres en Fraunces,
 * texte en Inter, accents terracotta (primaire) et olive (secondaire),
 * cartes arrondies à ombre douce, boutons/puces en pilule.
 */
:root {
  --cream-50: #fdfbf7;
  --cream-100: #faf5ec;
  --cream-200: #f3e9d7;

  --terracotta-50: #fdf3ef;
  --terracotta-100: #fbe3d8;
  --terracotta-200: #f5c3ab;
  --terracotta-300: #eb9d78;
  --terracotta-400: #e07a4d;
  --terracotta-500: #c85a32;
  --terracotta-600: #a94526;
  --terracotta-700: #88361f;

  --olive-50: #f4f6ef;
  --olive-100: #e6ebd9;
  --olive-200: #cdd8b3;
  --olive-500: #728a47;
  --olive-600: #596d37;
  --olive-700: #46552d;

  --charcoal-50: #f5f4f2;
  --charcoal-100: #e6e3de;
  --charcoal-300: #a8a099;
  --charcoal-500: #6b6259;
  --charcoal-700: #453f39;
  --charcoal-900: #2a2521;

  --shadow-soft: 0 1px 2px rgba(42, 37, 33, .04), 0 6px 16px -4px rgba(42, 37, 33, .08);
  --shadow-soft-hover: 0 2px 4px rgba(42, 37, 33, .06), 0 12px 24px -6px rgba(42, 37, 33, .14);
  --radius-xl2: 1.25rem;
}

* { box-sizing: border-box; }

body {
  font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  margin: 0;
  background: var(--cream-50);
  color: var(--charcoal-900);
  font-size: 15px;
  line-height: 1.55;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3 {
  font-family: 'Fraunces', ui-serif, Georgia, serif;
  color: var(--charcoal-900);
  font-weight: 600;
  letter-spacing: .1px;
}
h1 { font-size: 1.7rem; margin: 0 0 .3rem; }
h2 { font-size: 1.25rem; margin: 1.6rem 0 .8rem; }

/* --- En-tête / navigation (crème translucide, pilule terracotta active) --- */
header.topbar {
  background: rgba(253, 251, 247, .9);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: var(--charcoal-900);
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 62px;
  position: sticky;
  top: 0;
  z-index: 40;
  border-bottom: 1px solid rgba(42, 37, 33, .05);
}
header.topbar a { color: var(--charcoal-900); text-decoration: none; }
.brand {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 700;
  font-size: 1.2rem;
  letter-spacing: .1px;
  display: flex;
  align-items: center;
  gap: .55rem;
}
.brand .pastille {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--terracotta-500); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: .95rem; font-family: 'Fraunces', serif;
}
header.topbar nav { display: flex; align-items: center; gap: .2rem; }
header.topbar nav a {
  padding: .5rem .95rem; border-radius: 999px; font-size: .88rem; font-weight: 500;
  color: var(--charcoal-700); transition: background .15s ease, color .15s ease;
}
header.topbar nav a:hover { background: var(--cream-100); }
header.topbar nav a.actif { background: var(--terracotta-500); color: #fff; }
.topbar-user { display: flex; align-items: center; gap: .7rem; font-size: .85rem; color: var(--charcoal-700); }

.menu-toggle {
  display: none; background: transparent; border: none; color: var(--charcoal-700);
  cursor: pointer; padding: .4rem; line-height: 1; border-radius: 999px;
}
.menu-toggle:hover { background: var(--cream-100); }
.menu-toggle .icone { width: 24px; height: 24px; }

main.container { max-width: 1150px; margin: 1.5rem auto; padding: 0 1.2rem 3rem; }

/* --- Icônes trait (feather-style) --- */
.icone { width: 1em; height: 1em; display: inline-block; vertical-align: -0.15em; }

/* --- Cartes --- */
.card {
  background: #fff;
  border-radius: var(--radius-xl2);
  padding: 1.3rem 1.4rem;
  margin-bottom: 1.3rem;
  box-shadow: var(--shadow-soft);
  box-shadow: var(--shadow-soft), inset 0 0 0 1px rgba(42, 37, 33, .05);
}
.card-hover { transition: transform .2s ease, box-shadow .2s ease; }
.card-hover:hover { transform: translateY(-2px); box-shadow: var(--shadow-soft-hover); }

/* --- Tableaux --- */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .65rem .7rem; border-bottom: 1px solid var(--charcoal-100); text-align: left; font-size: .9rem; }
th { background: var(--cream-100); color: var(--charcoal-700); font-weight: 700; font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; }
tbody tr:nth-child(even) td { background: var(--cream-50); }
tr:hover td { background: var(--terracotta-50); }

table.sortable th[data-sort] { cursor: pointer; user-select: none; position: relative; padding-right: 1.4rem; }
table.sortable th[data-sort]:hover { background: var(--cream-200); }
table.sortable th[data-sort]::after { content: "\21C5"; position: absolute; right: .55rem; opacity: .4; font-size: .75rem; }
table.sortable th[data-sort].tri-asc::after { content: "\25B2"; opacity: .9; }
table.sortable th[data-sort].tri-desc::after { content: "\25BC"; opacity: .9; }

/* --- Boutons (pilules) --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  border-radius: 999px; padding: .55rem 1.2rem;
  font-size: .87rem; font-weight: 500; font-family: inherit;
  border: none; cursor: pointer; text-decoration: none;
  transition: background-color .15s ease, color .15s ease;
  min-height: 40px;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
/* .btn seul = primaire (terracotta plein) */
.btn { background: var(--terracotta-500); color: #fff; box-shadow: var(--shadow-soft); }
.btn:hover:not(:disabled) { background: var(--terracotta-600); }
.btn.secondaire {
  background: #fff; color: var(--charcoal-700);
  box-shadow: inset 0 0 0 1px var(--charcoal-100);
}
.btn.secondaire:hover:not(:disabled) { background: var(--cream-100); }
.btn.danger {
  background: #fff; color: var(--terracotta-600);
  box-shadow: inset 0 0 0 1px var(--terracotta-200);
}
.btn.danger:hover:not(:disabled) { background: var(--terracotta-50); }
.btn.petit { padding: .35rem .85rem; font-size: .78rem; min-height: 32px; }
.actions-ligne { display: flex; gap: .4rem; flex-wrap: wrap; }

/* --- Puces de filtre (chips) --- */
.chip {
  display: inline-flex; align-items: center; gap: .3rem; border-radius: 999px;
  padding: .3rem .8rem; font-size: .85rem; font-weight: 500; cursor: pointer;
  transition: background-color .15s ease, color .15s ease;
}
.chip-off { background: #fff; color: var(--charcoal-700); box-shadow: inset 0 0 0 1px var(--charcoal-100); }
.chip-off:hover { background: var(--cream-100); }
.chip-on { background: var(--olive-500); color: #fff; }

/* --- Formulaires --- */
label { display: block; margin: .8rem 0 .35rem; font-weight: 500; font-size: .85rem; color: var(--charcoal-700); }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], select, textarea {
  width: 100%; padding: .6rem .8rem; border: none; border-radius: .8rem;
  font-size: .95rem; background: #fff; color: var(--charcoal-900); font-family: inherit;
  box-shadow: var(--shadow-soft), inset 0 0 0 1px var(--charcoal-100);
}
input::placeholder, textarea::placeholder { color: var(--charcoal-300); }
input:focus, select:focus, textarea:focus {
  outline: none; box-shadow: var(--shadow-soft), inset 0 0 0 2px var(--terracotta-400);
}

.flash { padding: .8rem 1.1rem; border-radius: 1rem; margin-bottom: 1rem; font-size: .9rem; font-weight: 500; }
.flash.success { background: var(--olive-50); color: var(--olive-700); box-shadow: inset 0 0 0 1px var(--olive-200); }
.flash.error { background: var(--terracotta-50); color: var(--terracotta-700); box-shadow: inset 0 0 0 1px var(--terracotta-200); }

.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .2rem .65rem; border-radius: 999px; font-size: .74rem; font-weight: 600; background: var(--olive-50); color: var(--olive-700); box-shadow: inset 0 0 0 1px var(--olive-200); }
.badge.repos { background: var(--terracotta-50); color: var(--terracotta-700); box-shadow: inset 0 0 0 1px var(--terracotta-200); }

.grille-jours td.weekend { background: var(--terracotta-50); }
.toolbar { display: flex; gap: .6rem; align-items: center; margin-bottom: 1.1rem; flex-wrap: wrap; }
form.inline { display: inline; }
small.muted { color: var(--charcoal-500); }

/* --- Icônes circulaires (cartes KPI, écrans de pointage) --- */
.icone-cercle {
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--olive-50); color: var(--olive-700);
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.icone-cercle .icone { width: 22px; height: 22px; }
.icone-cercle.bordeaux, .icone-cercle.terracotta { background: var(--terracotta-50); color: var(--terracotta-600); }

/* --- Grille de cartes KPI --- */
.kpi-grille { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 1rem; margin-bottom: 1.3rem; }
.kpi-carte {
  background: #fff; border-radius: var(--radius-xl2);
  padding: 1.1rem 1.2rem; box-shadow: var(--shadow-soft); display: flex; align-items: center; gap: .8rem;
}
.kpi-carte .valeur { font-family: 'Fraunces', serif; font-weight: 600; font-size: 1.5rem; color: var(--charcoal-900); line-height: 1.1; }
.kpi-carte .label { font-size: .78rem; color: var(--charcoal-500); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }

/* --- Graphiques SVG --- */
.graphique-carte { padding-bottom: .8rem; }
.graphique-carte svg { width: 100%; height: auto; display: block; }
.graphique-legende { display: flex; gap: 1.2rem; font-size: .8rem; color: var(--charcoal-500); margin-top: .4rem; flex-wrap: wrap; }
.graphique-legende span { display: inline-flex; align-items: center; gap: .35rem; }
.pastille-legende { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

/* ================= RESPONSIVE ================= */
@media (max-width: 880px) {
  header.topbar { flex-wrap: wrap; height: auto; padding: .7rem 1rem; row-gap: .5rem; }
  .menu-toggle { display: inline-flex; }
  header.topbar nav {
    display: none; width: 100%; flex-direction: column; align-items: stretch;
    order: 3; padding-top: .4rem; border-top: 1px solid var(--charcoal-100);
  }
  header.topbar nav.ouvert { display: flex; }
  header.topbar nav a { padding: .7rem .9rem; border-radius: .8rem; }
  .topbar-user { order: 2; margin-left: auto; }
  main.container { margin: 1.1rem auto; padding: 0 .8rem 3rem; }
  h1 { font-size: 1.4rem; }
  .card { padding: 1rem; border-radius: 1rem; }
  th, td { padding: .5rem .5rem; font-size: .84rem; }
  .btn { padding: .6rem 1rem; }
  .kpi-grille { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 520px) {
  .kpi-grille { grid-template-columns: 1fr 1fr; gap: .6rem; }
  .kpi-carte { padding: .8rem .9rem; }
  .toolbar { gap: .4rem; }
  .btn.petit { flex: 1; }
  .actions-ligne { width: 100%; }
}

/* Tables larges (planning) : défilement horizontal tactile sur petit écran */
@media (max-width: 700px) {
  .table-scroll table { min-width: 640px; }
}
