:root {
  --bg: #f4f5f8;
  --card: #ffffff;
  --text: #18202f;
  --muted: #6b7280;
  --line: #e4e7ec;
  /* Couleurs du logo Pimpant : corail #FF856A + bleu étoile #3FC5EE */
  --primary: #ff856a;        /* surfaces : boutons, bordures, accents */
  --primary-ink: #c94c31;    /* texte corail lisible sur fond clair */
  --primary-soft: #ffede8;
  --ok: #157a46;      --ok-soft: #e3f5ea;
  --warn: #9a5b00;    --warn-soft: #fff3dc;
  --danger: #b42318;  --danger-soft: #fdeceb;
  --info: #0b7aa3;    --info-soft: #e2f6fd;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --nav-h: 0px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11141b; --card: #1a1f2a; --text: #e8eaf0; --muted: #9aa3b2; --line: #2b3242;
    --primary: #ff856a; --primary-ink: #ffa48f; --primary-soft: #3b2520;
    --ok: #4fd18b; --ok-soft: #173826; --warn: #f2b24c; --warn-soft: #3a2c12;
    --danger: #ff7b6e; --danger-soft: #3d1c1a; --info: #6fd3f5; --info-soft: #12313d;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--primary-ink); }
h1 { font-size: 1.45rem; margin: 0; line-height: 1.25; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 0 0 .5rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
[hidden] { display: none !important; }

.container { max-width: 1040px; margin: 0 auto; padding: 20px 16px calc(32px + var(--nav-h)); }

/* ---------- topbar / nav ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 20px;
  padding: 10px 20px; background: var(--card); border-bottom: 1px solid var(--line);
  border-top: 3px solid var(--primary);
}
.brand { display: flex; align-items: center; gap: 12px; font-weight: 700; color: var(--text); text-decoration: none; white-space: nowrap; }
.logo-img { display: block; height: 34px; width: auto; }
.app-label { padding-left: 12px; border-left: 1px solid var(--line); color: var(--muted); font-weight: 600; font-size: .95rem; }
@media (prefers-color-scheme: dark) { .logo-img { filter: brightness(1.05); } }
.nav { display: flex; gap: 4px; flex: 1; }
.nav a, .bottomnav a { text-decoration: none; color: var(--muted); font-weight: 500; }
.nav a { padding: 7px 12px; border-radius: 8px; }
.nav a:hover { background: var(--bg); color: var(--text); }
.nav a.active { background: var(--primary-soft); color: var(--primary-ink); }
.me { display: flex; align-items: center; gap: 10px; margin-left: auto; color: var(--muted); font-size: .9rem; white-space: nowrap; }

.bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; display: flex;
  background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.bottomnav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px; font-size: .72rem; }
.bottomnav a .ico { font-size: 1.25rem; line-height: 1; }
.bottomnav a.active { color: var(--primary-ink); }
.bottomnav .count, .nav .count {
  display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--danger); color: #fff;
  font-size: .7rem; line-height: 18px; text-align: center; margin-left: 4px;
}

@media (min-width: 761px) { .bottomnav { display: none !important; } }
@media (max-width: 760px) {
  .nav { display: none; }
  .logo-img { height: 28px; }
  .topbar .app-label { display: none; }
  .topbar { padding: 10px 16px; gap: 10px; }
  #me-name { display: none; }
  body.with-bottomnav { --nav-h: 62px; }
  h1 { font-size: 1.25rem; }
}

/* ---------- composants ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px; }
.card.flush { padding: 0; overflow: hidden; }
.card > .card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.card > .card-head h2 { margin: 0; }

.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-bottom: 16px; }
.page-head .sub { width: 100%; margin-top: -6px; }
.back { display: inline-block; margin-bottom: 8px; text-decoration: none; font-size: .9rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 42px; padding: 0 18px; border-radius: 10px; border: 1px solid transparent;
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap;
  background: var(--bg); color: var(--text); border-color: var(--line);
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn.ok { background: var(--ok); color: #fff; border-color: var(--ok); }
.btn.danger { color: var(--danger); background: transparent; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--bg); color: var(--text); }
.btn.sm { min-height: 32px; padding: 0 10px; font-size: .85rem; }
.btn.block { width: 100%; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.b-ok { background: var(--ok-soft); color: var(--ok); }
.b-warn { background: var(--warn-soft); color: var(--warn); }
.b-info { background: var(--info-soft); color: var(--info); }
.b-danger { background: var(--danger-soft); color: var(--danger); }
.b-muted { background: var(--bg); color: var(--muted); border: 1px solid var(--line); }

.banner { border-radius: 10px; padding: 12px 14px; margin-bottom: 16px; font-size: .93rem; }
.banner.ok { background: var(--ok-soft); color: var(--ok); }
.banner.warn { background: var(--warn-soft); color: var(--warn); }
.banner.info { background: var(--info-soft); color: var(--info); }
.banner.danger { background: var(--danger-soft); color: var(--danger); }
.banner a { color: inherit; font-weight: 600; }

label { display: block; font-weight: 600; font-size: .88rem; margin: 0 0 6px; }
input, select {
  width: 100%; min-height: 44px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--card); color: var(--text); font: inherit; font-size: 16px; /* 16px : pas de zoom iOS */
}
input:focus, select:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: transparent; }
.field { margin-bottom: 14px; }
.form-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); align-items: end; }
.form-grid .field { margin: 0; }
.error { color: var(--danger); font-size: .9rem; min-height: 1.2em; margin: 6px 0 0; }

/* ---------- login ---------- */
.auth { max-width: 400px; margin: 8vh auto 0; }
.auth .brand { flex-direction: column; gap: 6px; margin-bottom: 22px; }
.auth .logo-img { height: auto; width: min(260px, 70vw); }
.auth .app-label { border: 0; padding: 0; font-size: 1rem; }
.auth .links { text-align: center; margin-top: 14px; font-size: .9rem; }

/* ---------- calendrier ---------- */
.sheet-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.total { font-size: .95rem; color: var(--muted); }
.total strong { font-size: 1.5rem; color: var(--text); margin-left: 4px; }
.cal-head, .cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-head div { text-align: center; font-size: .75rem; font-weight: 600; color: var(--muted); text-transform: uppercase; padding-bottom: 4px; }
.cal-cell {
  position: relative; min-height: 74px; padding: 6px 8px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); font: inherit; text-align: left;
  display: flex; flex-direction: column; justify-content: space-between;
}
button.cal-cell { cursor: pointer; }
button.cal-cell:hover { border-color: var(--primary); }
.cal-cell.empty { border: 0; background: transparent; }
.cal-cell.we { background: var(--bg); }
.cal-cell.today { border: 2px solid var(--primary); }
.cal-d { font-size: .85rem; font-weight: 600; color: var(--muted); }
.cal-cell.has { background: var(--primary-soft); border-color: transparent; }
.cal-cell.has .cal-d { color: var(--primary-ink); }
.cal-h { align-self: flex-end; font-weight: 700; color: var(--primary-ink); font-size: 1rem; }
.cal-cell.changed::after { content: ""; position: absolute; top: 6px; right: 6px; width: 7px; height: 7px; border-radius: 50%; background: var(--warn); }
@media (max-width: 560px) {
  .card.sheet { padding: 12px 8px; }
  .cal-head, .cal-grid { gap: 3px; }
  .cal-cell { min-height: 52px; padding: 4px 5px; border-radius: 8px; }
  .cal-d { font-size: .75rem; }
  .cal-h { font-size: .8rem; }
}

.hint { font-size: .85rem; color: var(--muted); margin: 10px 2px 0; }

.daylist { list-style: none; margin: 0; padding: 0; }
.daylist li { display: flex; justify-content: space-between; gap: 10px; padding: 9px 2px; border-bottom: 1px solid var(--line); }
.daylist li:last-child { border-bottom: 0; }
.daylist .old { text-decoration: line-through; color: var(--muted); margin-right: 6px; font-weight: 400; }

.actions {
  position: sticky; bottom: var(--nav-h); z-index: 10; display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap;
  margin: 0 -16px 16px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-top: 1px solid var(--line);
}
body.with-bottomnav .actions { padding-bottom: 12px; }
@media (max-width: 560px) { .actions .btn { flex: 1; } }

/* ---------- listes ---------- */
.rows { list-style: none; margin: 0; padding: 0; }
.rows > li { border-bottom: 1px solid var(--line); }
.rows > li:last-child { border-bottom: 0; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; color: var(--text); text-decoration: none; }
a.row:hover { background: var(--bg); }
.row .grow { flex: 1; min-width: 0; }
.row .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .hours { font-weight: 700; min-width: 56px; text-align: right; font-variant-numeric: tabular-nums; }
.row .chev { color: var(--muted); }
.empty-state { padding: 22px 16px; text-align: center; color: var(--muted); }

.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.filters select { width: auto; flex: 1; min-width: 160px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; text-decoration: none; color: var(--text); }
.stat .v { font-size: 1.6rem; font-weight: 700; }
.stat .l { font-size: .85rem; color: var(--muted); }
a.stat:hover { border-color: var(--primary); }

/* tableau récap mois × salariés */
.table-wrap { overflow-x: auto; }
table.recap { border-collapse: collapse; width: 100%; font-size: .9rem; }
table.recap th, table.recap td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
table.recap th:first-child, table.recap td:first-child { text-align: left; position: sticky; left: 0; background: var(--card); }
table.recap thead th { color: var(--muted); font-weight: 600; font-size: .8rem; }
table.recap td a { text-decoration: none; font-weight: 600; font-variant-numeric: tabular-nums; }
table.recap .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-left: 6px; vertical-align: middle; }
.dot.validated { background: var(--ok); } .dot.submitted { background: var(--info); } .dot.draft { background: var(--warn); }
table.recap tfoot td { font-weight: 700; border-bottom: 0; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: .8rem; color: var(--muted); padding: 10px 16px; }

/* utilisateurs */
.user-row { display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; padding: 14px 16px; align-items: center; }
.user-row .meta { font-size: .85rem; color: var(--muted); overflow-wrap: anywhere; }
.user-row .ctrl { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.user-row select { width: auto; min-height: 36px; padding: 4px 8px; font-size: .9rem; }
@media (max-width: 640px) { .user-row { grid-template-columns: 1fr; } .user-row .ctrl { justify-content: flex-start; } }

/* ---------- modale ---------- */
dialog.modal { border: 0; border-radius: 16px; padding: 0; width: min(420px, calc(100vw - 24px)); background: var(--card); color: var(--text); box-shadow: 0 20px 50px rgba(0,0,0,.25); }
dialog.modal::backdrop { background: rgba(15, 20, 30, .45); }
dialog.modal form { padding: 20px; }
dialog.modal h3 { font-size: 1.1rem; margin-bottom: 14px; }
@media (max-width: 560px) {
  dialog.modal { margin: auto 0 0; width: 100vw; max-width: 100vw; border-radius: 18px 18px 0 0; padding-bottom: env(safe-area-inset-bottom); }
}
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 4px; }
.chip { flex: 1 0 60px; min-height: 40px; border: 1px solid var(--line); background: var(--bg); color: var(--text); border-radius: 10px; font: inherit; font-weight: 600; cursor: pointer; }
.chip:hover, .chip.on { border-color: var(--primary); color: var(--primary-ink); background: var(--primary-soft); }
.modal-actions { display: flex; gap: 8px; margin-top: 16px; align-items: center; }
.modal-actions .sp { flex: 1; }
.modal p.body { margin: 0 0 6px; }

/* ---------- toasts ---------- */
#toasts { position: fixed; z-index: 100; left: 50%; transform: translateX(-50%); bottom: calc(20px + var(--nav-h)); display: flex; flex-direction: column; gap: 8px; width: min(420px, calc(100vw - 32px)); }
.toast { padding: 12px 16px; border-radius: 10px; background: #18202f; color: #fff; box-shadow: 0 8px 24px rgba(0,0,0,.2); font-size: .93rem; animation: tin .2s ease-out; }
.toast.error { background: var(--danger); }
.toast.ok { background: var(--ok); }
@keyframes tin { from { opacity: 0; transform: translateY(8px); } }

.loading { color: var(--muted); padding: 40px 0; text-align: center; }
