/* Main courante – feuille de style unique, pensée d'abord pour le mobile */
:root {
  --brand: #7a1f1f; --brand-2: #a33a2a; --bg: #f5f3ef; --card: #fff; --text: #222; --muted: #6b6b6b;
  --line: #e2ded6; --pos: #1d7a3a; --pos-bg: #e3f4e8; --neg: #b3261e; --neg-bg: #fbe5e3;
  --we: #fff4c7; --ferie: #dbe9fb; --n1: #2f5fa7; --radius: 10px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--brand); }
h1 { font-size: 1.35rem; margin: .4rem 0 .8rem; }
h2 { font-size: 1.05rem; margin: 1rem 0 .5rem; }
code { background: #eee; padding: 0 .3em; border-radius: 4px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.strong { font-weight: 600; }
.mt { margin-top: 1rem; }

/* ---- En-tête et menu ---- */
.topbar { background: var(--brand); color: #fff; display: flex; align-items: center; flex-wrap: wrap; padding: .5rem 1rem; gap: .5rem; position: sticky; top: 0; z-index: 20; }
.brand { color: #fff; font-weight: 700; text-decoration: none; font-size: 1.1rem; }
.menu-toggle { margin-left: auto; background: none; border: 0; color: #fff; font-size: 1.5rem; cursor: pointer; }
.menu { display: none; width: 100%; flex-direction: column; gap: .2rem; padding-bottom: .5rem; }
.menu-open .menu { display: flex; }
.menu a, .menu .linklike { color: #fff; text-decoration: none; padding: .45rem .6rem; border-radius: 6px; font-size: 1rem; }
.menu a.active, .menu a:hover { background: rgba(255,255,255,.18); }
.menu-sep { flex: 1; }
.linklike { background: none; border: 0; cursor: pointer; font: inherit; text-align: left; }
form.inline { display: inline; }
@media (min-width: 860px) {
  .menu-toggle { display: none; }
  .menu { display: flex; flex-direction: row; width: auto; flex: 1; align-items: center; padding: 0; margin-left: 1.5rem; }
}
.subnav { display: flex; gap: .3rem; overflow-x: auto; margin: .2rem 0 1rem; padding-bottom: .2rem; }
.subnav a { white-space: nowrap; padding: .35rem .7rem; border-radius: 20px; background: #e9e4da; color: var(--text); text-decoration: none; font-size: .9rem; }
.subnav a.active { background: var(--brand); color: #fff; }

.container { max-width: 1500px; margin: 0 auto; padding: .8rem; }
.footer { text-align: center; color: var(--muted); font-size: .8rem; padding: 1.5rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem; }
details.card > summary { cursor: pointer; }
.auth { max-width: 420px; margin: 2rem auto; }
.auth.wide { max-width: 560px; }
.grid2, .grid4 { display: grid; gap: .8rem; grid-template-columns: 1fr; }
@media (min-width: 760px) { .grid2 { grid-template-columns: 1fr 1fr; } .grid4 { grid-template-columns: repeat(4, 1fr); } }

/* ---- Formulaires ---- */
label { display: block; margin-bottom: .7rem; font-weight: 500; }
label.inline { display: inline-flex; gap: .3rem; align-items: center; margin: 0; font-weight: normal; }
input, select, textarea { font: inherit; width: 100%; padding: .55rem .6rem; border: 1px solid #c9c3b8; border-radius: 8px; background: #fff; margin-top: .25rem; }
input[type=checkbox] { width: auto; margin: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-2); border-color: transparent; }
.filters { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.filters input, .filters select { width: auto; margin: 0; }
.w-small { width: 5rem; } .w-medium { max-width: 12rem; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset[disabled] input, fieldset[disabled] textarea { background: #f0eeea; }
legend { font-weight: 500; margin-bottom: .4rem; }
.switch { display: flex; align-items: center; gap: .5rem; font-weight: 500; cursor: pointer; }
.btn { display: inline-block; padding: .55rem 1rem; border-radius: 8px; border: 1px solid #c9c3b8; background: #fff; color: var(--text); text-decoration: none; cursor: pointer; font: inherit; font-weight: 500; }
.btn:hover { background: #f3f0ea; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-2); }
.btn-small { padding: .35rem .65rem; font-size: .9rem; }
.btn-large { padding: .85rem 1.4rem; font-size: 1.1rem; }
.btn-block { display: block; width: 100%; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .5rem; }
.lien { font-family: monospace; font-size: .85rem; }

.flash { padding: .7rem .9rem; border-radius: 8px; margin-bottom: .8rem; }
.flash-ok { background: var(--pos-bg); color: #13502a; }
.flash-err { background: var(--neg-bg); color: #7d1a14; }
.flash-warn { background: #fff1cc; color: #6b4d00; }
.flash-warn a { margin-left: .4rem; }
.flash-info { background: #e5eefb; color: #1f3e6b; }
.badge { display: inline-block; padding: .1rem .5rem; border-radius: 12px; font-size: .78rem; background: #e8e4dc; color: #444; margin-left: .3rem; vertical-align: middle; }
.badge-ok { background: var(--pos-bg); color: var(--pos); }
.badge-draft, .badge-warn { background: #fff1cc; color: #6b4d00; }
.badge-lock { background: #eee; color: #555; }
.badge-ferie { background: var(--ferie); color: #1f3e6b; }
.badge-we { background: var(--we); color: #6b4d00; }

/* ---- Saisie ---- */
.saisie-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .5rem; }
.jour-titre { margin: .2rem 0 .8rem; font-size: 1.05rem; }
.saisie .bloc { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem; margin: .8rem 0; }
.saisie .bloc h2 { margin: 0 0 .6rem; display: inline; }
.saisie summary { cursor: pointer; list-style: none; display: flex; justify-content: space-between; align-items: center; }
.saisie summary::-webkit-details-marker { display: none; }
.saisie summary::after { content: "▾"; color: var(--muted); }
.saisie details[open] summary { margin-bottom: .6rem; }
.champs { display: grid; gap: .6rem; grid-template-columns: 1fr 1fr; }
.champs label.big { grid-column: span 1; }
.champs label.big:nth-child(3) { grid-column: 1 / -1; }
@media (min-width: 760px) { .champs { grid-template-columns: repeat(3, 1fr); } .champs label.big:nth-child(3) { grid-column: auto; } #bloc-digital .champs { grid-template-columns: repeat(5, 1fr); } }
.champs input { font-size: 1.35rem; padding: .7rem; text-align: right; font-variant-numeric: tabular-nums; }
#bloc-digital .champs input { font-size: 1.1rem; }
.champs input.alerte { border-color: #d99a00; background: #fff8e1; }
.ref { display: block; color: var(--muted); font-weight: normal; font-size: .8rem; margin-top: .2rem; min-height: 1em; }
.totaux { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: .6rem; }
.totaux div { flex: 1 1 8rem; background: #f7f4ee; border-radius: 8px; padding: .5rem .7rem; }
.totaux span { display: block; font-size: .8rem; color: var(--muted); }
.totaux strong { font-size: 1.2rem; font-variant-numeric: tabular-nums; }
.tags { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .6rem; }
.chip { display: inline-flex; margin: 0; cursor: pointer; font-weight: normal; }
.chip input { position: absolute; opacity: 0; }
.chip span { padding: .4rem .8rem; border-radius: 18px; border: 1px solid #c9c3b8; background: #fff; }
.chip input:checked + span { background: var(--brand); border-color: var(--brand); color: #fff; }
.chip input:focus-visible + span { outline: 2px solid var(--brand-2); }
.actions-sticky { position: sticky; bottom: 0; background: var(--bg); padding: .7rem 0; display: flex; justify-content: flex-end; align-items: center; gap: 1rem; border-top: 1px solid var(--line); }
dialog { border: 0; border-radius: var(--radius); padding: 1.2rem; max-width: 30rem; width: 92%; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(0,0,0,.35); }
.dlg-actions { display: flex; gap: .5rem; justify-content: flex-end; flex-wrap: wrap; }

/* ---- Indicateurs ---- */
.kpis { display: grid; gap: .7rem; grid-template-columns: 1fr 1fr; margin-bottom: .6rem; }
@media (min-width: 900px) { .kpis { grid-template-columns: repeat(4, 1fr); } }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem; }
.kpi-titre { color: var(--muted); font-size: .85rem; }
.kpi-val { display: block; font-size: 1.6rem; margin: .1rem 0 .3rem; font-variant-numeric: tabular-nums; }
.kpi-ecarts { list-style: none; margin: 0; padding: 0; font-size: .85rem; }
.kpi-ecarts li { display: flex; gap: .35rem; align-items: baseline; flex-wrap: wrap; }
.kpi-ecarts li > span { width: 4.2rem; color: var(--muted); }
.kpi-ecarts em { font-style: normal; font-weight: 600; }
.pos { color: var(--pos); } .neg { color: var(--neg); }
td.pos { background: var(--pos-bg); } td.neg { background: var(--neg-bg); }

/* ---- Tableaux ---- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.table { border-collapse: collapse; width: 100%; font-size: .88rem; }
.table th, .table td { padding: .4rem .5rem; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.table thead th { background: #efe9df; font-weight: 600; font-size: .8rem; position: sticky; top: 0; }
.table tfoot th { background: #efe9df; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table input { margin: 0; padding: .35rem; }
.card .table-wrap { border: 0; }

/* Vue mois (proche du Google Sheet) */
.mois-wrap { max-height: 78vh; }
.mois { font-size: .82rem; }
.mois th, .mois td { padding: .3rem .4rem; border-right: 1px solid #eee; }
.mois tr.grp th { text-align: center; color: #fff; font-size: .78rem; }
.mois .g-couv { background: #d98c1f; } .mois .g-n1 { background: #5a87c9; } .mois .g-ca { background: #b8862e; }
.mois .g-moy { background: #8b6d3a; } .mois .g-dig { background: #6e5a8c; }
.mois thead tr:nth-child(2) th { top: 1.75rem; }
.mois .n1 { color: var(--n1); }
.mois tr.we td { background: var(--we); }
.mois tr.ferie td { background: var(--ferie); }
.mois tr.brouillon td { font-style: italic; color: #999; }
.mois tr.ferme td { color: var(--muted); }
.mois td.obs { max-width: 11rem; overflow: hidden; text-overflow: ellipsis; font-size: .78rem; }
.mois .sticky { position: sticky; left: 0; background: inherit; z-index: 1; }
.mois .sticky2 { position: sticky; left: 1.9rem; z-index: 1; }
.mois tbody td.sticky, .mois tbody td.sticky2 { background: #fff; font-weight: 600; }
.mois tr.we td.sticky, .mois tr.we td.sticky2 { background: var(--we); }
.mois tr.ferie td.sticky, .mois tr.ferie td.sticky2 { background: var(--ferie); }
.mois thead th.sticky, .mois thead th.sticky2 { z-index: 3; }
.legende { color: var(--muted); }
.sw { display: inline-block; width: .9rem; height: .9rem; border-radius: 3px; vertical-align: middle; margin: 0 .2rem 0 .6rem; border: 1px solid #ccc; }
.sw-we { background: var(--we); } .sw-ferie { background: var(--ferie); } .sw-draft { background: #eee; }
.recaps .card { margin-bottom: 0; }
.recap th { white-space: nowrap; }
.comment { border-bottom: 1px solid var(--line); padding: .5rem 0; }
.comment p { margin: .2rem 0 0; }
.form-inline { display: grid; gap: .5rem; margin-top: .8rem; }
@media (min-width: 760px) { .form-inline { grid-template-columns: 14rem 1fr auto; align-items: start; } .form-inline select, .form-inline textarea { margin: 0; } }
.pager { display: flex; gap: .8rem; align-items: center; justify-content: center; }
#t-digital-resume { margin-left: auto; margin-right: .6rem; color: var(--muted); }
@media (max-width: 759px) { .mois .hide-mob { display: none; } .mois-wrap { max-height: 70vh; } }
