/* Mise en page : une colonne étroite pour la feuille de semaine (téléphone), une grille large
   et défilable pour le suivi de la responsable, comme un tableau de pointage réglé par jour. */
:root {
  --bg: #f2f4f6;
  --surface: #ffffff;
  --surface-2: #e9eef3;
  --ink: #15202b;
  --muted: #5a6876;
  --line: #d3dbe3;
  --accent: #0f4c81;          /* bleu « stylo bille » des feuilles papier */
  --accent-ink: #ffffff;
  --accent-soft: #dde9f5;
  --marker: #f2a93b;          /* surligneur : aujourd'hui, en direct */
  --warn: #9a4a00;
  --warn-bg: #fdf0df;
  --warn-line: #efc48f;
  --ok: #1d6b3f;
  --ok-bg: #e2f2e8;
  --danger: #b3261e;
  --c0-bg: #e6e9ec; --c0-fg: #4a5561;
  --c1-bg: #dbe9f6; --c1-fg: #123b63;
  --c2-bg: #bcd6ee; --c2-fg: #0f3558;
  --c3-bg: #8cb8e0; --c3-fg: #0b2a47;
  --c4-bg: #4f8ec9; --c4-fg: #ffffff;
  --c5-bg: #2a6aa8; --c5-fg: #ffffff;
  --c6-bg: #174a7d; --c6-fg: #ffffff;
  --c7-bg: #6a3f99; --c7-fg: #ffffff;
  --font-display: "Avenir Next Condensed", "Roboto Condensed", "Arial Narrow", system-ui, sans-serif;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --radius: 10px;
  --shadow: 0 1px 2px rgb(15 40 70 / 8%), 0 2px 8px rgb(15 40 70 / 6%);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f151b; --surface: #17202a; --surface-2: #1e2934; --ink: #e6edf3; --muted: #9aa8b6; --line: #2c3a48;
    --accent: #7db4ea; --accent-ink: #0b1a29; --accent-soft: #1b3350; --marker: #f5b453;
    --warn: #f3b26b; --warn-bg: #3a2a16; --warn-line: #6b4a22; --ok: #7fd3a0; --ok-bg: #173a27; --danger: #ff8a80;
    --c0-bg: #2a333d; --c0-fg: #b8c3ce; --c1-bg: #1c3550; --c1-fg: #cfe3f7; --c2-bg: #22476d; --c2-fg: #e0eefb;
    --c3-bg: #2b5f92; --c3-fg: #ffffff; --c4-bg: #3b78b5; --c4-fg: #ffffff; --c5-bg: #5b96d4; --c5-fg: #0b1a29;
    --c6-bg: #8dbbeb; --c6-fg: #0b1a29; --c7-bg: #a784d6; --c7-fg: #160b24;
    --shadow: 0 1px 2px rgb(0 0 0 / 40%);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f151b; --surface: #17202a; --surface-2: #1e2934; --ink: #e6edf3; --muted: #9aa8b6; --line: #2c3a48;
  --accent: #7db4ea; --accent-ink: #0b1a29; --accent-soft: #1b3350; --marker: #f5b453;
  --warn: #f3b26b; --warn-bg: #3a2a16; --warn-line: #6b4a22; --ok: #7fd3a0; --ok-bg: #173a27; --danger: #ff8a80;
  --c0-bg: #2a333d; --c0-fg: #b8c3ce; --c1-bg: #1c3550; --c1-fg: #cfe3f7; --c2-bg: #22476d; --c2-fg: #e0eefb;
  --c3-bg: #2b5f92; --c3-fg: #ffffff; --c4-bg: #3b78b5; --c4-fg: #ffffff; --c5-bg: #5b96d4; --c5-fg: #0b1a29;
  --c6-bg: #8dbbeb; --c6-fg: #0b1a29; --c7-bg: #a784d6; --c7-fg: #160b24;
  --shadow: 0 1px 2px rgb(0 0 0 / 40%);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 var(--font-body);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
#app { min-height: 100%; }
h1, h2, h3 { font-family: var(--font-display); line-height: 1.15; margin: 0; text-wrap: balance; }
h1 { font-size: 2rem; font-weight: 700; }
h2 { font-size: 1.45rem; font-weight: 700; }
h3 { font-size: 1.1rem; font-weight: 600; }
p { margin: 0; }
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--marker); outline-offset: 2px; }
.booting { padding: 2rem 16px; color: var(--muted); }
.muted { color: var(--muted); }
.small, small { font-size: .82rem; }
.mono { font-family: var(--font-mono); font-size: .9rem; }
.lead { color: var(--muted); max-width: 60ch; }
.eyebrow { font-size: .75rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.pad { padding: .75rem 1rem; }
.note { color: var(--muted); font-size: .9rem; max-width: 70ch; }
.warn-text { color: var(--warn); }
.warn-box { background: var(--warn-bg); border: 1px solid var(--warn-line); color: var(--ink); padding: .7rem .9rem; border-radius: var(--radius); }
.stack { display: flex; flex-direction: column; gap: .75rem; }
.row { display: flex; align-items: center; gap: .5rem; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); gap: .75rem; }
ul.plain { list-style: none; margin: 0; padding: 0; display: grid; gap: .25rem; }

/* ---------- Boutons et champs ---------- */
.btn {
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: .1rem;
  min-height: 2.75rem; padding: .5rem 1rem; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font: 600 .95rem var(--font-body); cursor: pointer; text-align: center;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.small { min-height: 2.25rem; padding: .3rem .75rem; font-size: .85rem; }
.btn.big { min-height: 3.25rem; font-size: 1.05rem; width: 100%; }
.btn.big small { font-weight: 400; opacity: .85; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.link { background: none; border: 0; padding: .35rem 0; color: var(--accent); font: 600 .9rem var(--font-body); cursor: pointer; }
.link.danger { color: var(--danger); }
.icon-btn {
  width: 2.75rem; height: 2.75rem; flex: none; border-radius: 50%; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font-size: 1.4rem; line-height: 1; cursor: pointer;
}
.mini {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 999px;
  padding: .2rem .6rem; font: 600 .75rem var(--font-body); cursor: pointer; white-space: nowrap;
}
.mini.done { background: var(--ok-bg); border-color: transparent; color: var(--ok); }
.input {
  width: 100%; min-height: 2.75rem; padding: .5rem .75rem; border-radius: 8px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: 1rem var(--font-body);
}
.input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.form { display: flex; flex-direction: column; gap: 1rem; }
.field { display: flex; flex-direction: column; gap: .3rem; min-width: 0; }
.field label { font-weight: 600; font-size: .9rem; }
fieldset.card { display: flex; flex-direction: column; gap: .6rem; }
legend { font-family: var(--font-display); font-weight: 700; font-size: 1.1rem; padding: 0 .3rem; }
.check, .radio { display: flex; gap: .6rem; align-items: flex-start; cursor: pointer; }
.check input, .radio input { width: 1.2rem; height: 1.2rem; margin-top: .15rem; accent-color: var(--accent); flex: none; }
.radio span { display: flex; flex-direction: column; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; margin: 0; }

/* ---------- Codes (repères) : du plus proche (clair) au plus loin (foncé), 7 à part ---------- */
.code {
  display: inline-grid; place-items: center; min-width: 1.6rem; height: 1.6rem; padding: 0 .35rem; flex: none;
  border-radius: 6px; font: 700 .85rem var(--font-mono); font-variant-numeric: tabular-nums;
  background: var(--c0-bg); color: var(--c0-fg);
}
.c1 { background: var(--c1-bg); color: var(--c1-fg); }
.c2 { background: var(--c2-bg); color: var(--c2-fg); }
.c3 { background: var(--c3-bg); color: var(--c3-fg); }
.c4 { background: var(--c4-bg); color: var(--c4-fg); }
.c5 { background: var(--c5-bg); color: var(--c5-fg); }
.c6 { background: var(--c6-bg); color: var(--c6-fg); }
.c7 { background: var(--c7-bg); color: var(--c7-fg); }
.cunk { background: var(--warn-bg); color: var(--warn); border: 1px dashed var(--warn-line); }
.legend { display: flex; flex-wrap: wrap; gap: .4rem 1rem; font-size: .8rem; color: var(--muted); }
.legend-item { display: inline-flex; align-items: center; gap: .35rem; font-variant-numeric: tabular-nums; }

/* ---------- En-tête ---------- */
.demo-bar {
  display: flex; flex-wrap: wrap; gap: .25rem 1rem; align-items: center; justify-content: center;
  background: var(--marker); color: #2b1a00; font-size: .85rem; padding: .35rem 16px;
}
.demo-bar .link { color: #2b1a00; text-decoration: underline; }
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  padding: .75rem 16px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: .55rem; font: 700 1.2rem var(--font-display); letter-spacing: .01em; }
.brand-mark {
  width: 1.5rem; height: 1.5rem; border-radius: 6px; background: var(--accent);
  box-shadow: inset 0 -5px 0 var(--marker);
}
.who { display: flex; align-items: center; gap: .75rem; font-weight: 600; }
.tabs {
  display: flex; gap: .25rem; overflow-x: auto; padding: 0 16px; background: var(--surface);
  border-bottom: 1px solid var(--line); scrollbar-width: none;
}
.tab {
  padding: .75rem .9rem; color: var(--muted); text-decoration: none; font-weight: 600; white-space: nowrap;
  border-bottom: 3px solid transparent;
}
.tab[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); }
.view { padding: 1.25rem 16px 4rem; }

/* ---------- Connexion ---------- */
.auth { max-width: 26rem; margin: 0 auto; padding: 3rem 16px; display: flex; flex-direction: column; gap: 1.25rem; }
.user-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; }

/* ---------- Feuille de semaine (salarié) ---------- */
.week { max-width: 40rem; margin: 0 auto; display: flex; flex-direction: column; gap: 1rem; }
.week-nav { display: flex; align-items: center; gap: .75rem; }
.week-title { flex: 1; min-width: 0; text-align: center; display: flex; flex-direction: column; gap: .1rem; }
.week-status { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; justify-content: center; font-size: .9rem; }
.pill { display: inline-block; padding: .25rem .7rem; border-radius: 999px; font-weight: 600; font-size: .85rem; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.ok-soft { background: var(--accent-soft); color: var(--accent); }
.pill.neutral { background: var(--surface-2); color: var(--muted); }
.days { display: flex; flex-direction: column; gap: .75rem; }
.day {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .9rem; display: flex; flex-direction: column; gap: .75rem;
}
.day.today { border-color: var(--marker); box-shadow: 0 0 0 1px var(--marker); }
.day-head { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; }
.day-head h3 { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.day-hours { font: 600 .95rem var(--font-mono); color: var(--muted); font-variant-numeric: tabular-nums; }
.chip { font: 600 .7rem var(--font-body); text-transform: uppercase; letter-spacing: .06em; background: var(--marker); color: #2b1a00; padding: .1rem .45rem; border-radius: 4px; }
.types { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .3rem; }
.type-btn {
  min-height: 2.5rem; padding: .3rem .2rem; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--ink); font: 600 .82rem var(--font-body); cursor: pointer;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.type-btn[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.type-btn:disabled { cursor: default; }
.type-btn:disabled:not([aria-pressed="true"]) { opacity: .45; }
.entry { display: flex; flex-direction: column; gap: .6rem; }
.entry + .entry { border-top: 1px dashed var(--line); padding-top: .75rem; }
.entry-sub { display: flex; justify-content: space-between; align-items: center; }
.site-btn {
  display: flex; align-items: center; justify-content: space-between; gap: .75rem; width: 100%;
  min-height: 3.25rem; padding: .55rem .8rem; border-radius: var(--radius); cursor: pointer; text-align: left;
  border: 1px solid var(--line); background: var(--bg); color: var(--ink); font: inherit;
}
.site-btn:not(:disabled):hover { border-color: var(--accent); }
.site-btn:disabled { cursor: default; }
.placeholder { color: var(--accent); }
.pick-text { display: flex; flex-direction: column; min-width: 0; }
.pick-text strong { overflow-wrap: anywhere; }
.pick-text small { color: var(--muted); }
.times { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .5rem; }
.time { display: flex; flex-direction: column; gap: .2rem; font-size: .78rem; color: var(--muted); font-weight: 600; min-width: 0; }
.time input {
  width: 100%; min-height: 2.6rem; padding: .3rem .4rem; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font: 600 1rem var(--font-mono); font-variant-numeric: tabular-nums;
}
.day-actions { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.day-actions .danger:only-child { margin-left: auto; }

/* Plusieurs lieux dans une journée, commentaire */
.stops { display: flex; flex-direction: column; gap: .5rem; }
.stop { display: flex; align-items: center; gap: .5rem; }
.stop .site-btn { flex: 1; min-width: 0; }
.icon-btn.small { width: 2.4rem; height: 2.4rem; font-size: .9rem; }
.comment { display: flex; flex-direction: column; gap: .3rem; }
.comment label { font-size: .78rem; color: var(--muted); font-weight: 600; }
.comment textarea { min-height: 3.2rem; resize: vertical; font-size: .95rem; }
.comment-read {
  margin: 0; padding: .5rem .75rem; border-left: 3px solid var(--marker); background: var(--bg);
  border-radius: 0 8px 8px 0; font-size: .92rem; overflow-wrap: anywhere;
}
.note-mark { color: var(--muted); font-size: .85rem; flex: none; }

/* ---------- Choix du chantier ---------- */
.modal {
  width: min(34rem, calc(100vw - 24px)); max-height: min(44rem, calc(100dvh - 24px)); padding: 0;
  border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--ink);
  box-shadow: 0 20px 60px rgb(0 0 0 / 30%);
}
.modal.wide { width: min(56rem, calc(100vw - 24px)); }
.modal::backdrop { background: rgb(10 20 30 / 55%); }
.modal[open] { display: flex; flex-direction: column; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .9rem 1rem; border-bottom: 1px solid var(--line); }
.modal-head .icon-btn { width: 2.4rem; height: 2.4rem; font-size: 1rem; }
.modal-body { padding: 1rem; overflow-y: auto; display: flex; flex-direction: column; gap: .75rem; }
.pick-list { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; max-height: 22rem; overflow-y: auto; }
.pick-item {
  display: flex; align-items: center; justify-content: space-between; gap: .75rem; width: 100%;
  padding: .65rem .8rem; background: var(--surface); color: var(--ink); border: 0; border-bottom: 1px solid var(--line);
  text-align: left; font: inherit; cursor: pointer;
}
.pick-item:last-child { border-bottom: 0; }
.pick-item:hover, .pick-item:focus-visible { background: var(--accent-soft); }
.pick-group { padding: .45rem .8rem; background: var(--surface-2); font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; font-weight: 700; color: var(--muted); }
.pick-free { display: flex; flex-direction: column; gap: .35rem; padding-top: .25rem; }
.pick-free label { font-weight: 600; font-size: .9rem; }
.pick-free .row .input { flex: 1; min-width: 0; }
.entry-detail { display: flex; flex-direction: column; gap: .6rem; padding-bottom: .9rem; border-bottom: 1px solid var(--line); }
.entry-detail:last-child { border-bottom: 0; }

/* ---------- Écrans de la responsable ---------- */
.admin { max-width: 80rem; margin: 0 auto; display: flex; flex-direction: column; gap: 1rem; }
.admin.narrow { max-width: 48rem; }
.month-nav { display: flex; align-items: center; gap: .75rem; }
.month-nav h2 { min-width: 11rem; text-align: center; }
.stats { display: flex; flex-wrap: wrap; gap: .5rem; }
.stat {
  display: flex; align-items: center; gap: .5rem; padding: .5rem .85rem; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line); font-size: .9rem;
}
.stat strong { font: 700 1.3rem var(--font-display); font-variant-numeric: tabular-nums; }
.stat.warn { background: var(--warn-bg); border-color: var(--warn-line); }
.stat.attn { border-color: var(--accent); }
.stat.live { color: var(--muted); }
.dot { width: .6rem; height: .6rem; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px var(--ok-bg); }
@media (prefers-reduced-motion: no-preference) {
  .dot { animation: pulse 2s ease-in-out infinite; }
  @keyframes pulse { 50% { box-shadow: 0 0 0 6px transparent; } }
}
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: .88rem; }
th, td { padding: .45rem .6rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
thead th { position: sticky; top: 0; background: var(--surface-2); font-size: .8rem; white-space: nowrap; z-index: 1; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.zero { color: var(--line); }
td.strong { font-weight: 700; }
tfoot th, tfoot td { font-weight: 700; background: var(--surface-2); border-bottom: 0; }

table.grid { width: auto; }
table.grid th:first-child { position: sticky; left: 0; background: var(--surface); z-index: 2; }
table.grid thead th:first-child { background: var(--surface-2); }
table.grid td { padding: .2rem .25rem; min-width: 11rem; }
table.grid .date { font: 600 .8rem var(--font-mono); white-space: nowrap; color: var(--muted); }
table.grid tr.is-today th, table.grid tr.is-today td { background: color-mix(in srgb, var(--marker) 14%, var(--surface)); }
.week-row th, .week-row td { background: var(--surface-2); padding: .3rem .4rem; }
.week-row th { font-size: .78rem; white-space: nowrap; background: var(--surface-2) !important; }
.week-row .wk { display: flex; align-items: center; gap: .5rem; }
.cell {
  display: flex; align-items: center; justify-content: space-between; gap: .4rem; width: 100%;
  padding: .3rem .4rem; border-radius: 6px; border: 1px solid transparent; background: none; color: var(--ink);
  font: inherit; text-align: left; cursor: pointer;
}
.cell:hover { border-color: var(--line); background: var(--bg); }
.cell.warn { background: var(--warn-bg); border: 1px dashed var(--warn-line); }
.cell-site { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 11rem; }
.missing { font-size: .75rem; color: var(--muted); font-style: italic; padding-left: .4rem; }
.tag { font-size: .78rem; font-weight: 700; padding: .1rem .45rem; border-radius: 4px; background: var(--surface-2); color: var(--muted); }
.tag.t-cp { background: var(--ok-bg); color: var(--ok); }
.tag.t-maladie { background: var(--warn-bg); color: var(--warn); }
table.recap th small { display: block; font-weight: 500; color: var(--muted); }
table.recap thead .code { margin-bottom: .15rem; }
table.list.clickable tbody tr { cursor: pointer; }
table.list tbody tr:hover { background: var(--bg); }
tr.inactive { opacity: .5; }
.toolbar { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; }
.toolbar > .input { flex: 1 1 16rem; max-width: 28rem; }
.amounts { display: grid; grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr)); gap: .6rem; }
.amount { display: flex; align-items: center; gap: .4rem; }
.amount .input { min-width: 0; }

/* ---------- Message temporaire ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(1rem + env(safe-area-inset-bottom, 0px)); transform: translate(-50%, 150%);
  width: max-content; max-width: calc(100vw - 32px); padding: .6rem 1rem; border-radius: 999px; font-weight: 600; font-size: .9rem;
  background: var(--ink); color: var(--bg); box-shadow: var(--shadow); opacity: 0; pointer-events: none; z-index: 100;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.toast.err { background: var(--danger); color: #fff; border-radius: 12px; }
@media (prefers-reduced-motion: no-preference) {
  .toast { transition: transform .2s ease, opacity .2s ease; }
}

@media (max-width: 30rem) {
  .types { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .who > span { display: none; }
  h1 { font-size: 1.7rem; }
}
