:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #1d2733;
  --muted: #667585;
  --line: #dfe5ea;
  --accent: #1f6feb;
  --accent-soft: #e6f0ff;
  --danger: #d1324a;
  --ok: #1a9d5b;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: "Segoe UI", system-ui, sans-serif;
  font-size: 14px;
  color: var(--ink);
  background: var(--bg);
  overflow: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

#app { display: grid; grid-template-columns: 220px 1fr; height: 100vh; }

/* ---------- barre latérale ---------- */
#sidebar {
  background: #14202e;
  color: #cfd8e2;
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
  gap: 8px;
}
.brand { font-size: 17px; font-weight: 700; color: #fff; padding: 4px 8px 14px; display: flex; align-items: center; gap: 8px; }
.logo { width: 34px; height: 34px; border-radius: 8px; }
#sidebar nav { display: flex; flex-direction: column; gap: 3px; }
#sidebar nav button {
  text-align: left; background: none; border: 0; padding: 10px 12px; border-radius: 8px;
  color: #cfd8e2; cursor: pointer;
}
#sidebar nav button:hover { background: #1e2f43; }
#sidebar nav button.active { background: var(--accent); color: #fff; font-weight: 600; }
.nav-sep { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #6f8196; padding: 14px 12px 4px; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 6px; }
.side-foot .btn { background: #1e2f43; border-color: #2a3e55; color: #dfe7ef; text-align: left; }
.side-foot .btn:hover { background: #28405b; }
.hint { font-size: 11px; color: #6f8196; padding: 6px 4px 0; }

/* ---------- zone principale ---------- */
main { display: flex; flex-direction: column; min-width: 0; height: 100vh; overflow: hidden; }
#toolbar, #toolbar2 {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 20px; background: var(--panel);
}
#toolbar { border-bottom: 0; padding-bottom: 6px; }
#toolbar2 { border-bottom: 1px solid var(--line); padding-top: 6px; }
#toolbar h1 { font-size: 20px; margin: 0; font-weight: 700; }
#toolbar h1.cap, #printHeader h2.cap { text-transform: capitalize; }
.group { display: flex; align-items: center; gap: 8px; }
.sp { flex: 1; }
#toolbar label { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
#toolbar label.chk { color: var(--ink); cursor: pointer; }
#printNote { flex: 1; min-width: 240px; }

input[type=text], input[type=tel], input[type=email], input[type=password], input[type=number], input[type=date], select, textarea {
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; background: #fff; min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
textarea { resize: vertical; min-height: 70px; }

.btn {
  border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 7px 14px; cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: #f0f3f6; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover { background: #1558c2; }
.btn.danger { color: var(--danger); border-color: #f0c4cb; }
.btn.danger:hover { background: #fdecef; }
.btn.small { padding: 6px 10px; font-size: 13px; }
.btn.icon { padding: 5px 12px; font-size: 18px; line-height: 1; }

#content { flex: 1; overflow: auto; padding: 18px 20px 30px; }
#printHeader { display: none; }

/* ---------- semaine ---------- */
.week { display: grid; gap: 10px; align-items: start; min-width: 900px; }
.day { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); min-height: 360px; display: flex; flex-direction: column; }
.day.today { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.day-head { display: flex; align-items: center; justify-content: space-between; padding: 9px 10px; border-bottom: 1px solid var(--line); background: #fafbfc; border-radius: var(--radius) var(--radius) 0 0; }
.day.today .day-head { background: var(--accent-soft); }
.day-name { font-weight: 700; text-transform: capitalize; }
.day-date { color: var(--muted); font-size: 12px; }
.day-add { border: 0; background: none; font-size: 18px; color: var(--muted); cursor: pointer; border-radius: 6px; width: 26px; height: 26px; }
.day-add:hover { background: #e9edf1; color: var(--accent); }
.day-body { padding: 8px; display: flex; flex-direction: column; gap: 7px; flex: 1; }
.day.weekend .day-head { background: #f5f0ea; }

.card {
  border: 1px solid var(--line); border-left: 5px solid var(--c, #94a3b8); border-radius: 8px;
  padding: 7px 9px; background: #fff; cursor: pointer;
}
.card:hover { box-shadow: 0 2px 8px rgba(20, 32, 46, .12); }
.card-title { font-weight: 600; line-height: 1.3; }
.card-title .box { margin-right: 5px; color: var(--muted); }
.card-meta { color: var(--muted); font-size: 12px; margin-top: 2px; }
.card-notes { font-size: 12px; margin-top: 4px; color: #4a5866; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card.st-done { opacity: .55; }
.card.st-done .card-title .t { text-decoration: line-through; }
.card.st-doing { background: #fffbea; }
.mat { margin-top: 5px; padding: 4px 7px; border-radius: 6px; background: #eef4ff; border: 1px solid #cfdffb; font-size: 12px; font-weight: 600; color: #1b3f7a; }
.mat .route { display: block; font-weight: 400; color: #34527f; margin-top: 1px; }
.form-sep { margin-top: 6px; padding-top: 12px; border-top: 1px solid var(--line); font-weight: 700; font-size: 13px; color: var(--ink); }
.flag { margin-left: 6px; font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 99px; background: #ffe8c2; color: #8a5200; vertical-align: 1px; }
.pr-urgent .flag { background: #ffd9de; color: #a3162d; }
.span-tag { font-size: 11px; color: var(--muted); font-weight: 400; margin-left: 4px; }

/* ---------- mois ---------- */
.month-head, .month-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; min-width: 900px; }
.month-head div { text-align: center; font-weight: 600; color: var(--muted); text-transform: capitalize; padding: 4px 0 8px; }
.cell { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; min-height: 112px; padding: 5px; display: flex; flex-direction: column; gap: 3px; }
.cell.out { background: #eef1f4; opacity: .65; }
.cell.today { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.cell-top { display: flex; justify-content: space-between; align-items: center; font-weight: 600; font-size: 13px; }
.cell-top .day-add { width: 20px; height: 20px; font-size: 15px; }
.chip { font-size: 12px; padding: 2px 6px; border-radius: 5px; background: color-mix(in srgb, var(--c) 22%, #fff); border-left: 3px solid var(--c); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.chip.st-done { text-decoration: line-through; opacity: .6; }
.more { font-size: 11px; color: var(--muted); padding-left: 4px; }

/* ---------- tableau ---------- */
.table-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: #fafbfc; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
tbody tr { cursor: pointer; }
tbody tr:hover { background: #f6f9fc; }
tr.st-done td { color: var(--muted); }
tr.st-done .t { text-decoration: line-through; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
tfoot td { font-weight: 700; background: #fafbfc; cursor: default; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; background: var(--c, #94a3b8); }
.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; }
.badge.todo { background: #eceff3; color: #4a5866; }
.badge.doing { background: #fff1c2; color: #7a5600; }
.badge.done { background: #d5f3e3; color: #12683c; }

/* ---------- icônes (style pastilles) ---------- */
.ic { width: 1em; height: 1em; vertical-align: -.15em; flex: none; }
.btn .ic { font-size: 16px; margin-right: 3px; }
.btn.small .ic { font-size: 15px; }
#sidebar nav button { display: flex; align-items: center; gap: 10px; padding: 7px 10px; }
.side-foot .btn { display: flex; align-items: center; gap: 7px; }
.pic { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 8px; background: var(--pc, #4e8cf2); color: #fff; flex: none; }
.pic .ic { font-size: 16px; margin: 0; vertical-align: 0; }
.pic.sm { width: 26px; height: 26px; margin-right: 6px; vertical-align: middle; }
#sidebar nav button.active .pic { background: rgba(255, 255, 255, .25); }
.entity h3 { display: flex; align-items: center; }
.flag .ic { font-size: 11px; vertical-align: -1px; margin-right: 2px; }
.card-meta .ic, .mat .ic, .sub .ic { font-size: 13px; vertical-align: -2px; }
.card-notes, .table-wrap td .card-meta { white-space: pre-wrap; }

/* ---------- vue détaillée ---------- */
.dt-title { margin: 22px 0 10px; font-size: 16px; }
.dt-list { display: flex; flex-direction: column; gap: 10px; }
.dt { background: var(--panel); border: 1px solid var(--line); border-left: 6px solid var(--c, #94a3b8); border-radius: 10px; padding: 10px 14px; cursor: pointer; }
.dt:hover { box-shadow: 0 2px 8px rgba(20, 32, 46, .12); }
.dt.st-done { opacity: .6; }
.dt-head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.dt-head b { font-size: 15px; }
.dt-head .box { color: var(--muted); }
.dt-date { margin-left: auto; font-weight: 600; color: var(--muted); white-space: nowrap; }
.dt-meta { display: flex; gap: 14px; flex-wrap: wrap; color: var(--muted); font-size: 13px; margin-top: 4px; align-items: center; }
.dt .mat { display: inline-block; margin-top: 6px; }
.dt-notes { margin-top: 6px; white-space: pre-wrap; line-height: 1.5; }

/* ---------- rénovation ---------- */
.nav-sep.first { padding-top: 6px; }
.dv { display: inline-block; margin: 4px 4px 0 0; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 99px; background: #eceff3; color: #4a5866; }
.dv.ok { background: #d5f3e3; color: #12683c; }
.dv.ko { background: #ffe8c2; color: #8a5200; }
.occ-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
#dlgAsk h2 { margin: 0 0 10px; font-size: 18px; }
.flag.rep { background: #dff3f1; color: #0b5d57; }
.rep { color: #0b7a72; margin-left: 4px; }
.rep .ic { font-size: 13px; }
.card.reno { background: #f6f3ff; }
.flag.reno { background: #e5dcff; color: #4b2fa0; }
.checks { display: flex; flex-wrap: wrap; gap: 8px 18px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; }
#dlgAsk p { white-space: pre-line; }
.btn.on { background: #14202e; border-color: #14202e; color: #fff; }
.btn.on:hover { background: #1e2f43; }
.muted { color: var(--muted); font-size: 13px; line-height: 1.45; margin: 0 0 14px; }
.form-grid label.chk { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; font-size: 14px; color: var(--ink); cursor: pointer; }
.form-lbl { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.file-field .lbl { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.file-row { display: flex; align-items: center; gap: 8px; border: 1px dashed var(--line); border-radius: 8px; padding: 6px 10px; }
.file-row .fname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }

.res-tabs { display: flex; gap: 8px; flex-wrap: wrap; padding: 10px 20px; background: var(--panel); border-bottom: 1px solid var(--line); }
.res-tabs:empty { display: none; }
.res-tab { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line); background: #fff; border-radius: 99px; padding: 6px 14px; cursor: pointer; font-weight: 600; }
.res-tab:hover { background: #f0f3f6; }
.res-tab.on { background: var(--c, #14202e); border-color: var(--c, #14202e); color: #fff; }
.res-tab .n { font-size: 11px; font-weight: 700; background: rgba(0,0,0,.1); border-radius: 99px; padding: 0 7px; }
.res-tab.on .n { background: rgba(255,255,255,.28); }
.res-tab .dot { margin: 0; }
.res-tab.on .dot { background: #fff; }
.lg-res { display: inline-flex; align-items: center; margin-left: 10px; white-space: nowrap; color: var(--ink); font-weight: 600; }
.tl-controls { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; color: var(--muted); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; }
.seg button { border: 0; background: none; padding: 6px 13px; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--accent); color: #fff; font-weight: 600; }
.tl-legend { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.lg-red { color: #e24b4a; }
.lg-orange { color: #c27400; }
.lg-violet { color: #6a60d0; }
.tl-scroll { overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.tl { width: max-content; min-width: 100%; }
.tl-row { display: flex; border-bottom: 1px solid var(--line); }
.tl-label { position: sticky; left: 0; z-index: 4; flex: none; width: var(--lw); background: #fff; padding: 8px 10px; border-right: 1px solid var(--line); font-weight: 600; font-size: 13px; }
.tl-label small { display: block; color: var(--muted); font-weight: 400; font-size: 11px; }
.tl-head .tl-label { background: #fafbfc; }
.tl-months, .tl-days { display: flex; background: #fafbfc; }
.tl-m { flex: none; padding: 4px 6px; font-weight: 700; font-size: 12px; border-left: 1px solid var(--line); text-transform: capitalize; overflow: hidden; white-space: nowrap; }
.tl-d { flex: none; font-size: 10px; text-align: center; border-left: 1px solid var(--line); color: var(--muted); padding: 2px 0; overflow: hidden; white-space: nowrap; border-top: 1px solid var(--line); }
.tl-d small { display: block; }
.tl-lane {
  position: relative; flex: none;
  background-image:
    linear-gradient(90deg, transparent calc(var(--dw) * 5), #f6f1ea calc(var(--dw) * 5)),
    repeating-linear-gradient(90deg, #e3e8ed 0, #e3e8ed 1px, transparent 1px, transparent calc(var(--dw) * 7));
  background-size: calc(var(--dw) * 7) 100%, auto;
  background-repeat: repeat-x, repeat;
}
.tl-bar {
  position: absolute; z-index: 2; height: 24px; line-height: 22px; padding: 0 7px; font-size: 12px; color: #10202f;
  border-radius: 6px; border: 1px solid var(--c); border-left: 5px solid var(--c);
  background: color-mix(in srgb, var(--c) 28%, #fff); overflow: hidden; white-space: nowrap; cursor: pointer;
}
.tl-bar:hover { filter: brightness(.95); }

/* glisser-déposer : la barre se cale jour par jour */
.tl-bar.can-drag { cursor: grab; touch-action: none; user-select: none; }
.tl-bar.dragging { cursor: grabbing; z-index: 3; filter: none; box-shadow: 0 6px 16px rgba(20, 32, 46, .3); transition: transform .09s cubic-bezier(.2, .9, .3, 1.35), left .09s cubic-bezier(.2, .9, .3, 1.35), width .09s cubic-bezier(.2, .9, .3, 1.35); }
.tl-h { position: absolute; top: 0; bottom: 0; width: 8px; cursor: ew-resize; z-index: 3; }
.tl-h.l { left: 0; }
.tl-h.r { right: 0; }
.tl-bar.can-drag:hover .tl-h::after, .tl-bar.dragging .tl-h::after { content: ''; position: absolute; top: 5px; bottom: 5px; width: 2px; border-radius: 2px; background: var(--c); opacity: .7; }
.tl-h.l::after { left: 3px; }
.tl-h.r::after { right: 3px; }
.tl-ghost { position: absolute; z-index: 1; box-sizing: border-box; border: 2px dashed var(--c); border-radius: 6px; opacity: .55; pointer-events: none; }
.tl-snapcols { position: absolute; top: 0; bottom: 0; z-index: 1; background: rgba(31, 111, 235, .11); border-left: 1px solid var(--accent); border-right: 1px solid var(--accent); pointer-events: none; transition: left .09s ease-out, width .09s ease-out; }
.tl-tip { position: fixed; z-index: 140; padding: 5px 10px; border-radius: 8px; background: #14202e; color: #fff; font-size: 12px; font-weight: 600; white-space: nowrap; pointer-events: none; }
.tl-tip::first-letter { text-transform: uppercase; }
body.tl-dragging, body.tl-dragging * { cursor: grabbing !important; user-select: none !important; }

/* vues Semaine et Mois de la Rénovation : on dépose la carte ou la pastille sur un jour */
.card.can-move, .chip.can-move { cursor: grab; user-select: none; }
.moving-src { opacity: .3; }
.dd-clone { position: fixed; z-index: 130; margin: 0; pointer-events: none; opacity: .95; box-shadow: 0 10px 24px rgba(20, 32, 46, .3); transform: rotate(1.2deg); }
.day.drop-target, .cell.drop-target { outline: 2px solid var(--accent); outline-offset: -2px; background: var(--accent-soft); animation: dd-pop .14s ease-out; }
@keyframes dd-pop { from { transform: scale(.98); } to { transform: scale(1); } }

/* message avec « Annuler » */
#toast button { margin-left: 14px; padding: 4px 12px; border: 1px solid rgba(255, 255, 255, .5); border-radius: 99px; background: none; color: #fff; font: inherit; font-weight: 600; cursor: pointer; }
#toast button:hover { background: rgba(255, 255, 255, .15); }
#toast:has(.toast-warn) { border-radius: 16px; max-width: min(92vw, 640px); }
#toast .toast-warn { display: block; margin-top: 4px; font-size: 12px; color: #ffd98a; }
#toast .toast-warn .ic { vertical-align: -2px; }
.tl-bar.st-doing { background: color-mix(in srgb, var(--c) 55%, #fff); }
.tl-bar.st-done { opacity: .5; }
/* pointillés : la couleur dit d'où vient le problème (rouge : deux interventions ; orange : travail courant ; violet : absence) ; en cas de cause multiple, le rouge l'emporte */
.tl-bar.clash-abs { outline: 2px dashed #7f77dd; outline-offset: 1px; }
.tl-bar.clash-task { outline: 2px dashed #e08a00; outline-offset: 1px; }
.tl-bar.clash-reno { outline: 2px dashed #e24b4a; outline-offset: 1px; }
.tl-today { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--accent); opacity: .55; z-index: 1; }

/* ---------- fiches résidences / ouvriers ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.entity { background: var(--panel); border: 1px solid var(--line); border-top: 5px solid var(--c, var(--accent)); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; }
.entity h3 { margin: 0; font-size: 17px; }
.entity .sub { color: var(--muted); font-size: 13px; }
.progress { height: 8px; border-radius: 99px; background: #e8ecf0; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--ok); }
.counts { display: flex; gap: 8px; flex-wrap: wrap; }
.next { margin: 0; padding: 0; list-style: none; font-size: 13px; display: flex; flex-direction: column; gap: 4px; }
.next li { display: flex; gap: 8px; }
.next .d { color: var(--muted); min-width: 56px; }
.entity .row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }

.empty { text-align: center; color: var(--muted); padding: 60px 20px; background: var(--panel); border: 1px dashed var(--line); border-radius: var(--radius); }
.empty h3 { color: var(--ink); margin: 0 0 6px; }

/* ---------- formulaires ---------- */
dialog { border: 0; border-radius: 14px; padding: 0; box-shadow: 0 20px 60px rgba(10, 20, 35, .35); width: min(620px, 94vw); color: var(--ink); }
dialog::backdrop { background: rgba(15, 25, 38, .45); }
dialog form { padding: 22px 24px; }
dialog h2 { margin: 0 0 16px; font-size: 19px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--muted); }
.form-grid input, .form-grid select, .form-grid textarea { font-weight: 400; color: var(--ink); font-size: 14px; }
.form-grid input[type=color] { padding: 2px; height: 36px; width: 80px; }
.actions { display: flex; gap: 8px; margin-top: 20px; align-items: center; }
#dlgAsk form { padding: 22px 24px; }
#dlgAsk p { margin: 0; line-height: 1.5; }

#toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: #14202e; color: #fff; padding: 10px 18px; border-radius: 99px; box-shadow: 0 6px 20px rgba(0, 0, 0, .3); z-index: 99; }

/* ---------- feuille de travail (impression) ---------- */
#sheet { display: none; }
body.print-sheet #sheet { display: block; position: absolute; left: -99999px; top: 0; visibility: hidden; width: var(--cw); background: #fff; }
.sh-sheet { font-size: 13.5px; line-height: 1.4; color: #111; background: #fff; break-after: page; }
.sh-sheet:last-child { break-after: auto; }
.sh-sheet .ic { font-size: 13px; vertical-align: -2px; }
.sh-head { border-bottom: 2px solid #14202e; padding-bottom: 6px; margin-bottom: 10px; }
.sh-top { display: flex; justify-content: space-between; font-size: 11px; color: #555; }
.sh-head h2 { margin: 2px 0 3px; font-size: 24px; }
.sh-sub { font-size: 14px; }
.sh-note { margin-top: 6px; padding: 6px 9px; background: #fff7d6; border: 1px solid #e8d48a; border-radius: 5px; font-size: 13.5px; white-space: pre-wrap; }
.sh-note:empty { display: none; }
.sh-day { break-inside: avoid; margin-bottom: 10px; }
.sh-day h4 { margin: 0 0 3px; padding: 3px 2px; border-bottom: 2px solid #14202e; font-size: 15px; font-weight: 700; color: #14202e; }
.sh-res { margin: 6px 0 2px; padding: 2px 8px; border-left: 5px solid var(--c, #94a3b8); background: #f1f3f5; font-size: 13px; }
.sh-res b { font-size: 14px; text-transform: uppercase; letter-spacing: .02em; }
.sh-tbl { width: 100%; border-collapse: collapse; table-layout: fixed; }
.sh-tbl td { border-bottom: 1px solid #d3d8dd; padding: 4px 6px; vertical-align: top; overflow-wrap: anywhere; }
.sh-box { width: 24px; text-align: center; font-size: 17px; line-height: 1.1; }
.sh-who { width: 22%; font-size: 12.5px; color: #333; }
.sh-title { font-size: 15px; font-weight: 700; }
.sh-dim { color: #555; font-size: 11.5px; font-weight: 400; }
.sh-flag { font-size: 10.5px; text-transform: uppercase; border: 1.5px solid #111; border-radius: 3px; padding: 0 4px; margin-left: 6px; vertical-align: 1px; }
.sh-mat { margin-top: 2px; font-weight: 600; font-size: 13px; }
.sh-dev { margin-top: 2px; color: #333; font-size: 12.5px; }
.sh-notes { margin: 3px 0 1px 4px; font-size: 13px; color: #222; }
.sh-plain { white-space: pre-wrap; }
.sh-nl { display: flex; gap: 6px; align-items: baseline; margin: 1px 0; }
.sh-cb { font-size: 14px; flex: none; }
.sh-cont td { color: #555; font-size: 12px; padding-top: 2px; padding-bottom: 2px; }
.sh-empty { padding: 3px 8px; color: #777; font-style: italic; }
.checks.people { max-height: 150px; overflow: auto; }
.people-all { flex-basis: 100%; font-size: 12px; color: var(--muted); }

/* ---------- impression ---------- */
@media print {
  html, body { height: auto; overflow: visible; background: #fff; font-size: 11px; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  #app { display: block; height: auto; }
  #sidebar, #toolbar, #toolbar2, #resTabs, .day-add, dialog, #toast { display: none !important; }
  body.print-sheet #app, body.print-sheet dialog { display: none !important; }
  body.print-sheet #sheet { position: static; left: auto; visibility: visible; width: auto; }
  body.print-sheet { overflow: visible; height: auto; }
  main { display: block; height: auto; overflow: visible; }
  #content { overflow: visible; padding: 0; }

  #printHeader { display: block; margin-bottom: 10px; padding-bottom: 8px; border-bottom: 2px solid #14202e; }
  .ph-top { display: flex; justify-content: space-between; font-size: 10px; color: #666; }
  #printHeader h2 { margin: 3px 0 2px; font-size: 20px; }
  #printSub { font-size: 12px; color: #333; }
  #printNoteOut { margin-top: 6px; padding: 6px 9px; background: #fff7d6; border: 1px solid #e8d48a; border-radius: 5px; font-size: 12px; }
  #printNoteOut:empty { display: none; }

  .week, .month-head, .month-grid { min-width: 0; gap: 5px; }
  .day { min-height: 0; border-color: #999; border-radius: 4px; break-inside: avoid; }
  .day-head { border-radius: 3px 3px 0 0; padding: 5px 6px; }
  .day.today { box-shadow: none; border-color: #999; }
  .day.today .day-head { background: #fafbfc; }
  .week.print-fill .day { min-height: 135mm; }
  .card { break-inside: avoid; border-color: #bbb; border-left-width: 5px; cursor: auto; }
  .card-notes { display: block; -webkit-line-clamp: unset; overflow: visible; }
  .dt { break-inside: avoid; border-color: #bbb; border-left-width: 6px; cursor: auto; }
  .dt-title { break-after: avoid; margin-top: 14px; }
  .dt-list { gap: 6px; }
  .card.st-done { opacity: .6; }
  .cell { min-height: 24mm; border-color: #999; }
  .cell.today { box-shadow: none; border-color: #999; }
  .table-wrap { border-color: #999; border-radius: 0; }
  tr { break-inside: avoid; }
  th { background: #eee !important; }
  .entity { break-inside: avoid; }
  .entity .row { display: none; }
  .cards { grid-template-columns: 1fr 1fr; }
  .tl-controls { display: none; }
  .tl-scroll { overflow: visible; border-radius: 0; border-color: #999; }
  .tl-label { position: static; }
  .tl-row { break-inside: avoid; }
  .tl-bar { cursor: auto; }
  .tl-legend { color: #333; }
}

/* =====================  version en ligne  ===================== */
#auth { position: fixed; inset: 0; z-index: 200; background: #14202e; display: flex; align-items: center; justify-content: center; padding: 16px; overflow: auto; }
#auth[hidden] { display: none !important; }
.auth-card { background: #fff; border-radius: 14px; padding: 26px 28px; width: min(420px, 100%); box-shadow: 0 20px 60px rgba(0, 0, 0, .4); }
.auth-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; margin-bottom: 14px; }
.auth-brand img { width: 34px; height: 34px; border-radius: 8px; }
.auth-card h2 { margin: 0 0 10px; font-size: 20px; }
.auth-card form { display: flex; flex-direction: column; gap: 12px; }
.auth-card label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--muted); }
.auth-card input { font-size: 15px; font-weight: 400; color: var(--ink); padding: 9px 11px; }
.auth-card .btn { padding: 10px 14px; justify-content: center; }
.auth-msg { color: var(--muted); line-height: 1.5; margin: 0 0 10px; }
.auth-hint { color: var(--muted); font-size: 12px; margin: 14px 0 0; }
.auth-err { background: #fdecef; color: #a3162d; border: 1px solid #f0c4cb; border-radius: 8px; padding: 8px 10px; font-size: 13px; }

#userbox { padding: 10px; border-top: 1px solid #243649; margin-top: 4px; }
.ub-name { color: #fff; font-weight: 600; font-size: 13px; }
.ub-role { color: #8fa3b8; font-size: 12px; margin-bottom: 8px; }
.ub-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.ub-actions .btn { flex: 1; justify-content: center; }

.users-head { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.linkbox { width: 100%; margin-top: 6px; padding: 9px 10px; font-family: Consolas, monospace; font-size: 12px; }
.nowrap { white-space: nowrap; }
.card-wnote, .dt-wnote { margin-top: 4px; padding: 3px 7px; border-radius: 6px; background: #e8f5ee; color: #12683c; font-size: 12px; }
.wd-meta { color: var(--muted); margin: 0 0 10px; }
.wd-notes { white-space: pre-wrap; background: #f6f8fa; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin-bottom: 10px; }
.wd-label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--muted); margin-top: 10px; }
.wd-label textarea { font-weight: 400; color: var(--ink); font-size: 14px; }

/* ce que chaque rôle voit : le serveur fait respecter les droits, ici on retire seulement les boutons inutiles */
body.role-worker #btnNew, body.role-worker #btnAnon, body.role-worker .day-add,
body.role-worker [data-action=new-task], body.role-worker [data-action=new-int], body.role-worker [data-action=new-contr],
body.role-worker [data-action=new-res], body.role-worker [data-action=new-worker],
body.role-manager [data-action=new-res], body.role-manager [data-action=edit-res],
body.role-requester #btnNew, body.role-requester #btnAnon, body.role-requester .day-add,
body.role-requester [data-action=new-task], body.role-requester [data-action=new-int], body.role-requester [data-action=new-contr],
body.role-requester [data-action=new-res], body.role-requester [data-action=new-worker] { display: none !important; }
.inbox-item.ro { cursor: default; }
body[data-page=today] #toolbar2, body[data-page=today] #filters, body[data-page=today] #nav, body[data-page=today] #resTabs, body[data-page=users] #toolbar2, body[data-page=users] #filters, body[data-page=users] #nav, body[data-page=users] #resTabs, body[data-page=absences] #toolbar2, body[data-page=absences] #filters, body[data-page=absences] #nav, body[data-page=absences] #resTabs { display: none !important; }

/* téléphone : une colonne, menu défilant */
@media (max-width: 820px) {
  html, body { height: auto; }
  body { overflow: auto; }
  #app { display: flex; flex-direction: column; height: auto; min-height: 100vh; }
  #sidebar { flex-direction: column; padding: 8px 10px; gap: 4px; }
  .brand { padding: 2px 4px 4px; }
  #sidebar nav { flex-direction: row; overflow-x: auto; gap: 6px; padding-bottom: 4px; }
  #sidebar nav button { flex: none; padding: 6px 10px; white-space: nowrap; }
  .nav-sep { display: none; }
  .side-foot { flex-direction: row; flex-wrap: wrap; margin-top: 0; }
  #userbox { border-top: 0; padding: 4px; }
  main { height: auto; overflow: visible; }
  #content { overflow: visible; padding: 12px; }
  #toolbar, #toolbar2 { padding: 10px 12px; }
  .week { min-width: 0; grid-template-columns: 1fr !important; }
  .day { min-height: 0; }
  .month-head, .month-grid { min-width: 0; gap: 3px; }
  .cell { min-height: 64px; padding: 3px; }
  .table-wrap { overflow-x: auto; }
  table { min-width: 560px; }
  .tl-scroll { max-width: 100%; }
  .form-grid { grid-template-columns: 1fr; }
}

/* mot de passe oublié : alertes pour l'administrateur */
.nav-badge { margin-left: auto; min-width: 18px; padding: 0 6px; border-radius: 99px; background: #e0446a; color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; }
.nav-badge[hidden] { display: none !important; }
.badge.warn { background: #ffe0e6; color: #a3162d; }
.alert-box { margin: 0 0 14px; padding: 10px 14px; border-radius: var(--radius); background: #fff3d6; border: 1px solid #ecd28a; color: #5a4100; line-height: 1.5; }
.alert-box .ic { vertical-align: -2px; }
tr.has-request td { background: #fffaf0; }

/* recherche par numéro de TVA */
.lookup-row { display: flex; gap: 8px; align-items: center; }
.lookup-row input { flex: 1; min-width: 0; }
.lookup-status { display: block; min-height: 16px; margin-top: 4px; font-size: 12px; font-weight: 400; color: var(--muted); }
.lookup-status.ok { color: #12683c; }
.lookup-status.err { color: #a3162d; }

/* filtres « plusieurs à la fois » (ouvriers, intervenants) */
.msel-wrap { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.msel { position: relative; }
.msel-btn { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 120px; max-width: 240px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); cursor: pointer; font-size: 14px; }
.msel-btn:hover, .msel.open .msel-btn { border-color: var(--accent); }
.msel-txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msel-caret { color: var(--muted); font-size: 11px; }
.msel-panel { position: absolute; z-index: 60; top: calc(100% + 4px); left: 0; min-width: 230px; max-height: 340px; overflow: auto; padding: 6px; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgba(20, 32, 46, .18); }
.msel-panel[hidden] { display: none; }
#toolbar .msel-row, .msel-row { display: flex; align-items: center; gap: 8px; padding: 7px 8px; border-radius: 6px; cursor: pointer; color: var(--ink); font-size: 14px; }
.msel-row:hover { background: #f0f3f6; }
.msel-row.all { margin-bottom: 4px; border-bottom: 1px solid var(--line); border-radius: 6px 6px 0 0; font-weight: 600; }
body.role-worker #fWorkerWrap { display: none; }

/* absences et report du travail */
.abs-band { margin: 0 0 6px; padding: 5px 8px; border-radius: 6px; background: repeating-linear-gradient(135deg, #fde7e7 0 7px, #fbd5d5 7px 14px); color: #8a1d1d; font-size: 12px; font-weight: 600; }
.abs-band .ic { font-size: 13px; vertical-align: -2px; }
.chip.abs { background: #fde7e7; border-left-color: #d9534f; color: #8a1d1d; font-weight: 600; cursor: default; }
.abs-line { display: flex; align-items: center; gap: 6px; font-size: 12px; color: #8a1d1d; cursor: pointer; }
.abs-line:hover { text-decoration: underline; }
.sh-abs { margin: 3px 0; padding: 3px 8px; background: #fde7e7; border: 1px solid #e9b3b3; color: #8a1d1d; font-weight: 700; font-size: 13px; }
.shift-table td, .shift-table th { padding: 7px 10px; }
.shift-table tr.dim td { color: var(--muted); background: #fafbfc; }
.warn-list { margin: 6px 0 0; padding-left: 18px; }
dialog:has(.shift) { width: min(860px, 96vw); }

/* Ma journée : la page d'accueil de l'ouvrier (grosses zones à toucher, lisible dehors) */
.tj { max-width: 720px; margin: 0 auto; display: flex; flex-direction: column; gap: 12px; }
.tj-hello { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.tj-hello h2 { margin: 0; font-size: 26px; }
.tj-date { color: var(--muted); font-size: 15px; }
.tj-date::first-letter { text-transform: uppercase; }
.tj-days { display: flex; gap: 6px; }
.tj-days .btn { min-height: 44px; padding: 0 14px; font-size: 16px; }
.tj-days .btn[disabled] { opacity: .5; cursor: default; }
.tj-away { padding: 12px 14px; border-radius: 12px; background: #fde7e7; color: #8a1d1d; font-weight: 600; }
.tj-away .ic { vertical-align: -2px; }
.tj-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tj-stat { border-radius: 14px; padding: 12px; text-align: center; font-size: 14px; font-weight: 600; }
.tj-stat b { display: block; font-size: 34px; line-height: 1.1; }
.tj-stat.todo { background: #fff3d6; color: #7a5200; }
.tj-stat.done { background: #e8f5ee; color: #12683c; }
.tj-bar { height: 10px; border-radius: 99px; background: #e4e9ee; overflow: hidden; }
.tj-bar i { display: block; height: 100%; background: #2da66b; border-radius: 99px; transition: width .25s; }
.tj-route { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px; border-radius: 14px; background: var(--accent-soft); color: var(--accent); border: 1px solid #bcd3fb; font-weight: 700; font-size: 16px; text-decoration: none; }
.tj-card { background: var(--panel); border: 1px solid var(--line); border-left: 8px solid var(--c, #94a3b8); border-radius: 14px; overflow: hidden; }
.tj-card.open { border-color: var(--c, var(--line)); box-shadow: 0 2px 10px rgba(20, 32, 46, .08); }
.tj-card.done { background: #f6f8fa; }
.tj-head { display: flex; align-items: center; gap: 10px; width: 100%; padding: 14px; background: none; border: 0; text-align: left; cursor: pointer; font: inherit; color: inherit; min-height: 60px; }
.tj-state { width: 24px; flex: none; color: #2da66b; font-size: 22px; }
.tj-state:empty { display: none; }
body[data-page=today] #toolbar { display: none; }
.tj-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.tj-title { font-size: 18px; font-weight: 700; line-height: 1.25; }
.tj-sub { font-size: 13px; color: var(--muted); }
.tj-card.done .tj-title { text-decoration: line-through; color: var(--muted); }
.tj-flag { flex: none; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 99px; background: #ffe8c2; color: #8a5200; }
.tj-flag.urgent { background: #ffd9de; color: #a3162d; }
.tj-flag.doing { background: var(--accent-soft); color: var(--accent); }
.tj-flag.reno { background: #fde8e0; color: #9a3412; }
.tj-flag .ic { vertical-align: -2px; }
.tj-chev { flex: none; color: var(--muted); font-size: 20px; transition: transform .15s; }
.tj-card.open .tj-chev { transform: rotate(180deg); }
.tj-body { padding: 0 14px 14px; display: flex; flex-direction: column; gap: 10px; }
.tj-addr { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 15px; }
.tj-addr > span { flex: 1; min-width: 140px; }
.tj-lines-head { font-weight: 700; font-size: 14px; margin-top: 2px; }
.tj-hint { font-weight: 400; color: var(--muted); font-size: 12px; }
.tj-count { float: right; color: var(--muted); font-weight: 600; font-size: 13px; }
.tj-line { display: flex; align-items: flex-start; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: #fafbfc; font-size: 16px; line-height: 1.35; cursor: pointer; }
.tj-line input { width: 24px; height: 24px; flex: none; margin: 0; accent-color: #2da66b; cursor: pointer; }
.tj-line.on { background: #f1f8f4; }
.tj-line.on span { color: var(--muted); text-decoration: line-through; }
.tj-body .mat { margin-top: 0; padding: 10px 12px; font-size: 14px; border-radius: 12px; }
.tj-wnote { padding: 10px 12px; border-radius: 12px; background: #e8f5ee; color: #12683c; font-size: 14px; }
.tj-wnote .ic { vertical-align: -2px; }
.tj-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.tj-big { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 58px; border: 0; border-radius: 14px; font-size: 19px; font-weight: 700; cursor: pointer; }
.tj-big.ok { background: #2da66b; color: #fff; }
.tj-big.ok:hover { background: #249058; }
.tj-big.undo { background: #fff; color: var(--ink); border: 1px solid var(--line); }
a.tj-btn, button.tj-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 46px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--line); background: #fff; color: var(--ink); font: inherit; font-weight: 600; font-size: 15px; text-decoration: none; cursor: pointer; }
a.tj-btn.route { background: var(--accent-soft); color: var(--accent); border-color: #bcd3fb; }
.tj-tomorrow { text-align: center; color: var(--muted); font-size: 14px; padding: 4px 0 12px; }
@media (max-width: 820px) { .tj-hello h2 { font-size: 24px; } }

/* =====================  Boîte de dépôt, panier, tri  ===================== */
body[data-page=inbox] #toolbar2, body[data-page=inbox] #filters, body[data-page=inbox] #nav, body[data-page=inbox] #resTabs { display: none !important; }
.bx { max-width: 760px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
.bx-intro { margin: 0; color: var(--muted); line-height: 1.5; }
.bx-add { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.bx-add textarea { width: 100%; min-height: 96px; font-size: 15px; line-height: 1.5; }
.bx-add-row { display: flex; gap: 8px; flex-wrap: wrap; }
.bx-add-row select { flex: 1; min-width: 140px; }
.bx-head { display: flex; align-items: center; gap: 10px; }
.bx-group h3 { margin: 6px 0 8px; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.bx-group h3 .n, .bk-head .n { background: #eef1f4; color: var(--muted); border-radius: 99px; padding: 1px 8px; font-size: 12px; font-weight: 600; }
.inbox-item { display: flex; align-items: center; gap: 10px; background: var(--panel); border: 1px solid var(--line); border-left: 5px solid var(--c, #94a3b8); border-radius: 10px; padding: 8px 10px; margin-bottom: 8px; cursor: grab; user-select: none; }
.inbox-item.urgent { border-color: #f0b4bd; border-left-color: var(--c, #94a3b8); }
.ib-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; cursor: pointer; }
.ib-title { font-weight: 600; overflow-wrap: anywhere; }
.ib-sub, .ib-note { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

#btnBasket .n { background: var(--accent); color: #fff; border-radius: 99px; padding: 0 7px; font-size: 12px; margin-left: 4px; }
#btnBasket.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
#basket { position: fixed; top: 0; right: 0; bottom: 0; width: 300px; z-index: 50; background: var(--panel); border-left: 1px solid var(--line); box-shadow: -8px 0 24px rgba(20, 32, 46, .1); display: flex; flex-direction: column; gap: 10px; padding: 14px; }
body.basket-open main { padding-right: 300px; }
.bk-head { display: flex; align-items: center; gap: 8px; }
#bkAdd input { width: 100%; }
.bk-list { flex: 1; overflow: auto; margin: 0 -4px; padding: 0 4px; }
.bk-list .inbox-item { padding: 7px 8px; }
.bk-list .inbox-item .btn { padding: 4px 8px; font-size: 12px; }
.bk-hint { font-size: 12px; color: var(--muted); line-height: 1.45; }
.bk-empty { text-align: center; color: var(--muted); padding: 24px 0; font-size: 13px; }
.tl-lane.drop-target { background-color: rgba(31, 111, 235, .07); }

dialog:has(.plan) { width: min(560px, 96vw); }
.plan { display: flex; flex-direction: column; gap: 8px; }
.plan-step { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.plan-done { background: #e8f5ee; color: #12683c; border-radius: 10px; padding: 8px 10px; font-size: 13px; }
.plan-done .ic { vertical-align: -2px; }
.plan h2 { margin: 0; }
.plan-meta { color: var(--muted); display: flex; align-items: center; gap: 6px; font-size: 13px; }
.plan-meta .urgent { color: var(--danger); }
.plan-notes { white-space: pre-wrap; background: #f6f8fa; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 13px; }
.plan-lbl { font-size: 12px; font-weight: 700; color: var(--muted); margin-top: 6px; }
.plan-days { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-day { padding: 9px 12px; border: 1px solid var(--line); background: #fff; border-radius: 10px; cursor: pointer; font-size: 14px; }
.chip-day:first-letter { text-transform: uppercase; }
.chip-day.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.plan-date { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.plan-dur { display: flex; align-items: center; gap: 12px; }
.plan-range { color: var(--muted); font-size: 13px; }
.plan-who { display: flex; flex-direction: column; gap: 6px; }
.who { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.who input { width: 20px; height: 20px; flex: none; margin: 0; }
.who .nm { flex: 1; display: flex; flex-direction: column; font-weight: 600; }
.who small { color: var(--muted); font-size: 11px; font-weight: 400; }
.who .dot2 { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.who.free .dot2 { background: #2da66b; }
.who.busy .dot2 { background: #e5a000; }
.who.abs .dot2 { background: #d9534f; }
.who .st { font-size: 12px; font-weight: 600; }
.who.free .st { color: #12683c; }
.who.busy .st { color: #8a5200; }
.who.abs .st { color: #a3162d; }
.who.abs { background: #fff5f5; }
.plan-hint { font-size: 12px; color: var(--muted); }
.plan > select { width: 100%; }
.plan-actions { margin-top: 8px; }

@media print { #basket, #tabbar, #msheet { display: none !important; } body.basket-open main { padding-right: 0; } }

/* =====================  Version téléphone (tous les rôles)  ===================== */
#tabbar, #msheet { display: none; }
#btnFilters { display: none; }
.cell .dots, .month-day { display: none; }
@media (max-width: 820px) {
  html, body { height: auto; }
  body { overflow: auto; font-size: 15px; padding-bottom: calc(68px + env(safe-area-inset-bottom)); }
  #app { display: block; height: auto; min-height: 100vh; }
  #sidebar { display: none; }
  main { height: auto; overflow: visible; padding-right: 0 !important; }
  #basket, #btnBasket { display: none !important; }

  #toolbar { position: sticky; top: 0; z-index: 40; flex-wrap: wrap; gap: 8px; padding: calc(8px + env(safe-area-inset-top)) 12px 8px; border-bottom: 1px solid var(--line); }
  #toolbar h1 { flex: 1 1 100%; min-width: 0; font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #toolbar #nav { margin-left: auto; }
  #toolbar .sp { display: none; }
  #btnFilters { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; }
  body[data-page=inbox] #btnFilters, body[data-page=users] #btnFilters, body[data-page=absences] #btnFilters, body[data-page=residences] #btnFilters, body[data-page=workers] #btnFilters, body[data-page=rcontractors] #btnFilters { display: none; }
  #nav { gap: 4px; }
  #nav .btn { min-height: 40px; padding: 0 12px; }
  #filters { display: none; width: 100%; flex-wrap: wrap; gap: 10px; }
  body.filters-open #filters { display: flex; }
  #toolbar2 { display: contents; }
  #toolbar2 > :not(#btnNew) { display: none; }
  body.filters-open #toolbar2 { display: flex; flex-wrap: wrap; gap: 8px; padding: 8px 12px; background: var(--panel); border-bottom: 1px solid var(--line); }
  body.filters-open #toolbar2 > :not(#btnNew):not(#btnBasket):not(#printNote) { display: inline-flex; }
  #btnNew { position: fixed; right: 14px; bottom: calc(80px + env(safe-area-inset-bottom)); z-index: 45; min-height: 52px; padding: 0 20px; border-radius: 99px; font-size: 16px; box-shadow: 0 8px 20px rgba(20, 32, 46, .35); }
  #content { overflow: visible; padding: 12px 12px 24px; }
  .res-tabs { flex-wrap: nowrap; overflow-x: auto; padding-left: 12px; padding-right: 12px; }
  .res-tab { flex: none; }

  input[type=text], input[type=tel], input[type=email], input[type=password], input[type=number], input[type=date], select, textarea { font-size: 16px; min-height: 44px; }
  .btn { min-height: 44px; }
  .btn.small { min-height: 40px; }

  /* menu du bas */
  #tabbar:not([hidden]) { display: flex; }
  #tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; gap: 2px; padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); background: #14202e; border-top: 1px solid #243a52; }
  #tabbar button { position: relative; flex: 1; min-width: 0; min-height: 52px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; background: none; border: 0; border-radius: 12px; color: #9fb0c3; font-size: 11px; }
  #tabbar button .ic { font-size: 23px; }
  #tabbar button.active { background: #1e2f43; color: #fff; }
  .tab-badge { position: absolute; top: 2px; left: 55%; min-width: 18px; padding: 0 5px; border-radius: 99px; background: #e0446a; color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; }
  #msheet:not([hidden]) { display: flex; }
  #msheet { position: fixed; inset: 0; z-index: 70; flex-direction: column; justify-content: flex-end; }
  .ms-back { position: absolute; inset: 0; background: rgba(15, 25, 38, .5); }
  .ms-panel { position: relative; max-height: 80vh; overflow: auto; background: #fff; border-radius: 18px 18px 0 0; padding: 6px 12px calc(14px + env(safe-area-inset-bottom)); }
  .ms-title { padding: 12px 8px 6px; color: var(--muted); font-size: 13px; font-weight: 600; }
  .ms-item { display: flex; align-items: center; gap: 14px; width: 100%; padding: 14px 10px; background: none; border: 0; border-radius: 12px; font-size: 16px; text-align: left; cursor: pointer; }
  .ms-item .ic { font-size: 22px; color: var(--muted); }
  .ms-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
  .ms-item.active .ic { color: var(--accent); }

  /* formulaires en plein écran */
  #dlg { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 0; }
  #dlg form { min-height: 100%; display: flex; flex-direction: column; padding: calc(14px + env(safe-area-inset-top)) 14px 0; }
  #dlg .form-grid { flex: 1; align-content: start; }
  #dlg .actions { position: sticky; bottom: 0; margin: 12px -14px 0; padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); background: #fff; border-top: 1px solid var(--line); flex-wrap: wrap; }
  #dlgAsk { width: 94vw; }
  #toast { bottom: calc(82px + env(safe-area-inset-bottom)); max-width: 92vw; border-radius: 16px; }

  /* tableaux : une carte par ligne */
  .table-wrap { overflow: visible; background: none; border: 0; }
  table, tbody, tfoot { display: block; min-width: 0; }
  thead { display: none; }
  tr { display: block; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; margin-bottom: 10px; }
  td { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 5px 0; border: 0; text-align: right; }
  td::before { content: attr(data-label); flex: none; max-width: 42%; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; text-align: left; }
  td[data-label=""]::before { display: none; }
  tr.has-request td { background: none; }
  .cards { grid-template-columns: 1fr; }

  /* mois : des points colorés, et la liste du jour touché sous la grille */
  .month-head div { font-size: 11px; padding-bottom: 4px; }
  .cell { min-height: 54px; padding: 4px 2px; align-items: center; cursor: pointer; }
  .cell-top { width: 100%; justify-content: center; }
  .cell .day-add, .cell .chip, .cell .more { display: none; }
  .cell .dots { display: flex; flex-wrap: wrap; justify-content: center; gap: 3px; max-width: 100%; }
  .cell .dots i { display: block; width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
  .cell .dots i.abs { border-radius: 2px; background: #d9534f; }
  .cell.sel { outline: 2px solid var(--accent); outline-offset: -2px; }
  .month-day { display: block; margin-top: 14px; }
  .month-day h3 { margin: 0 0 8px; font-size: 16px; }
  .month-day h3::first-letter { text-transform: uppercase; }
  .month-day .none { padding: 16px; text-align: center; color: var(--muted); background: var(--panel); border: 1px dashed var(--line); border-radius: 10px; }

  /* la boîte et le tri */
  .bx-add-row select, .bx-add-row .btn { flex: 1 1 100%; }
  .inbox-item { padding: 10px; }
  .inbox-item .btn { min-height: 44px; }
  .chip-day { min-height: 44px; }
  .who { padding: 12px 10px; }
  .plan-actions { position: sticky; bottom: 0; background: #fff; padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
  .tl-label { padding: 6px 8px; font-size: 12px; }
}

/* =====================  Taille du texte sur téléphone (réglable : Petit / Normal / Grand)  ===================== */
:root { --pz: .88; }
@media (max-width: 820px) {
  #content { zoom: var(--pz); }
  /* les champs gardent 16 px réels : en dessous, l'iPhone zoome tout seul quand on touche un champ */
  #content input[type=text], #content input[type=tel], #content input[type=email], #content input[type=password], #content input[type=number], #content input[type=date], #content select, #content textarea { font-size: calc(16px / var(--pz)); min-height: calc(44px / var(--pz)); }
  #content .btn { min-height: calc(44px / var(--pz)); }
  #content .btn.small { min-height: calc(40px / var(--pz)); }
  body { font-size: 14px; }
  #toolbar h1 { font-size: 16px; }
  #toolbar .btn { font-size: 14px; }
  .ms-item { font-size: 15px; }
  .ms-title { font-size: 12px; }
  #tabbar button { font-size: 10.5px; }
}
