/* CRM de la démo : écrans du bureau (tableau de bord, planning, demandes, fiches) et
   documents A4 imprimables. S'appuie sur les jetons de styles.css (charte injectée). */

:root {
  --t-entretien: var(--green);
  --t-depannage: var(--red);
  --t-travaux: var(--blue);
  --t-pose: var(--accent);
}

/* --- Utilitaires ------------------------------------------------------------------- */
.mr-auto { margin-right: auto; }
.mt-6 { margin-top: 6px; }
.grow { flex: 1; min-width: 0; }
.block { display: block; }
.strong { font-weight: 700; }
.nowrap { white-space: nowrap; }
.center { text-align: center; }
.right { text-align: right; }
.pad { padding: 14px 16px; }
.stack-sm { display: flex; flex-direction: column; gap: 14px; }
.gap-12 { gap: 12px; }
.hint { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-3); font-size: 12px; }
.tone-text-red { color: var(--red); }
.tone-text-blue { color: var(--blue); }
.clip { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clip-1 { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prose { white-space: pre-line; color: var(--ink); line-height: 1.55; }
.quote { font-style: italic; color: var(--ink-2); }
.eyebrow { display: block; font-size: 12.5px; font-weight: 600; color: var(--brand); margin-bottom: 4px; letter-spacing: .01em; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex: none; }
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--ink-3); text-decoration: none; font-weight: 600; font-size: 13px; margin-bottom: 10px; }
.back:hover { color: var(--brand); }
.card-body.flush { padding: 0; }
.card-head > div { min-width: 0; }
.card-head a.small { color: var(--brand); font-weight: 600; text-decoration: none; }

.btn-sm { padding: 5px 10px; font-size: 12.5px; border-radius: 7px; gap: 5px; }
.btn.is-on { border-color: var(--brand); color: var(--brand-dark); background: var(--brand-soft); }
a.btn { text-decoration: none; }
.seg { display: inline-flex; align-items: center; gap: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.seg .btn { border-color: transparent; }

/* Types d'intervention */
.type-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--ink-2); white-space: nowrap; }
.type-chip::before { content: ''; width: 8px; height: 8px; border-radius: 2px; background: var(--tc, var(--gray)); }
.type-entretien { --tc: var(--t-entretien); }
.type-depannage { --tc: var(--t-depannage); }
.type-travaux { --tc: var(--t-travaux); }
.type-dot { display: inline-block; width: 7px; height: 7px; border-radius: 2px; background: var(--tc); margin-right: 8px; vertical-align: 1px; }
.urgent-tag { display: inline-flex; align-items: center; gap: 3px; color: var(--red); font-weight: 700; font-size: 11.5px; margin-right: 8px; }
.fluid { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; color: var(--blue); }

/* --- Barre d'outils, filtres, recherche ----------------------------------------------- */
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar .input.auto { width: auto; min-width: 150px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); font-weight: 600; font-size: 13px; color: var(--ink-2); cursor: pointer; }
.chip:hover { border-color: #c9cec8; color: var(--ink); }
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.chip em { font-style: normal; font-size: 11.5px; padding: 0 6px; border-radius: 9px; background: var(--line-2); color: var(--ink-3); line-height: 17px; }
.chip.on em { background: rgba(255,255,255,.2); color: #fff; }
.search { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 0 11px; min-width: 260px; margin-left: auto; color: var(--ink-3); }
.search.grow { margin-left: 0; }
.search input { border: 0; outline: none; padding: 9px 0; flex: 1; min-width: 0; background: none; color: var(--ink); }
.search:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 15%, transparent); }
.legend { display: flex; gap: 14px; margin-left: auto; color: var(--ink-3); font-size: 12px; font-weight: 600; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .lg { width: 10px; height: 10px; border-radius: 3px; background: var(--tc); }

/* --- Chiffres en tête de liste -------------------------------------------------------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; box-shadow: var(--shadow); }
.stat span { font-size: 12.5px; font-weight: 600; color: var(--ink-3); }
.stat b { font-size: 21px; letter-spacing: -.01em; }
.stat small { color: var(--ink-3); font-size: 12px; }
.stat-alert b { color: var(--red); }

/* --- Tableaux ----------------------------------------------------------------------- */
.table-wrap { overflow-x: auto; }
.table-wrap .table { min-width: 720px; }
.table td small.block { margin-top: 1px; font-size: 12px; }
.table.compact td { padding: 8px 14px; }
.table.compact th { padding: 8px 14px; }
.table tr.row-alert td:first-child { box-shadow: inset 3px 0 0 var(--red); }
.table thead th { background: #fafbf9; }
.more { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 12px; border-top: 1px solid var(--line-2); }

/* --- Fiches : grille, blocs clé/valeur ------------------------------------------------ */
.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.kv { display: flex; flex-direction: column; gap: 4px; }
.kv a { color: var(--brand-dark); }
.kv a.strong { text-decoration: none; font-size: 15px; }
.kv .sep { height: 1px; background: var(--line-2); margin: 8px 0; }
.kv .row { gap: 6px; color: var(--ink-2); }
.access { display: flex; gap: 6px; align-items: flex-start; margin-top: 6px; padding: 8px 10px; border-radius: 8px; background: var(--amber-soft); color: #7a4a00; font-size: 12.5px; }
.access .icon { margin-top: 2px; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 8px 0 0; font-size: 13px; }
.facts dt { color: var(--ink-3); }
.facts dd { margin: 0; font-weight: 600; }
.eq-history { display: flex; flex-direction: column; gap: 4px; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line-2); }
.eq-history a { color: var(--ink-2); text-decoration: none; font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.eq-history a:hover { color: var(--brand); }
.eq-history .num { color: var(--ink-3); margin-right: 6px; }
.links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.links a { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 8px; background: var(--line-2); color: var(--ink-2); text-decoration: none; font-weight: 600; font-size: 12.5px; }
.links a:hover { background: var(--brand-soft); color: var(--brand-dark); }
.person { display: flex; align-items: center; gap: 12px; }
.person small { display: block; color: var(--ink-3); font-size: 12px; }
.when { display: flex; align-items: center; gap: 6px; margin-top: 12px; padding: 9px 11px; border-radius: 8px; background: var(--brand-soft); color: var(--brand-dark); flex-wrap: wrap; }
.when .muted { color: color-mix(in srgb, var(--brand-dark) 70%, white); }
.mini-list { list-style: none; margin: 0; padding: 0; }
.mini-list li + li { border-top: 1px solid var(--line-2); }
.mini-list a { display: flex; justify-content: space-between; gap: 10px; padding: 10px 16px; text-decoration: none; }
.mini-list a:hover { background: #fafbf9; }
.mini-list span { display: flex; flex-direction: column; gap: 2px; }
.mini-list span.right { align-items: flex-end; }
.mini-item { display: flex; flex-direction: column; gap: 2px; }
.mini-item + .mini-item { border-top: 1px solid var(--line-2); padding-top: 8px; margin-top: 6px; }
.site-access { display: flex; gap: 6px; align-items: center; padding: 8px 16px; background: #fbfaf5; border-bottom: 1px solid var(--line-2); color: var(--ink-2); font-size: 12.5px; }
.sig-thumb { max-width: 220px; max-height: 90px; border: 1px solid var(--line); border-radius: 8px; background: #fff; padding: 4px; margin-top: 6px; }
.live-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: var(--green); }
.live-pill i, .fstate.live i { width: 8px; height: 8px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 0 currentColor; animation: pulse 1.8s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, currentColor 45%, transparent); } 70% { box-shadow: 0 0 0 7px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }

/* --- Tableau de bord ------------------------------------------------------------------ */
/* Un seul écart entre les blocs, quels qu'ils soient (la carte Chantiers n'existe que chez les poseurs). */
.dashboard { display: flex; flex-direction: column; gap: 16px; }
.dashboard > .page-head { margin-bottom: 4px; }
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.tile { display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; box-shadow: var(--shadow); transition: border-color .15s, transform .15s, box-shadow .15s; }
.tile:hover { border-color: color-mix(in srgb, var(--brand) 45%, var(--line)); transform: translateY(-1px); box-shadow: 0 2px 4px rgba(16,24,20,.06), 0 8px 24px rgba(16,24,20,.07); }
.tile-top { display: flex; align-items: center; gap: 10px; }
.tile-icon { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; }
.tile-label { font-weight: 600; color: var(--ink-2); font-size: 13px; }
.tile-value { font-size: 28px; line-height: 1.1; margin-top: 6px; letter-spacing: -.02em; }
.tile-sub { color: var(--ink-3); font-size: 12.5px; }
.tile-alert .tile-value { color: var(--red); }
.dash-grid { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 16px; align-items: start; }

.field-list { list-style: none; margin: 0; padding: 4px 0; }
.frow { display: grid; grid-template-columns: 34px 150px minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 9px 16px; cursor: pointer; }
.frow + .frow { border-top: 1px solid var(--line-2); }
.frow:hover { background: #fafbf9; }
.frow-who b { display: block; font-size: 13.5px; }
.frow-who { min-width: 0; }
.frow-who small { display: flex; align-items: center; gap: 6px; color: var(--ink-3); font-size: 12px; min-width: 0; }
.frow-who small span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.frow-what { min-width: 0; font-size: 13px; }
.frow-what small { font-size: 12px; }
.frow-state { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; }
.fstate { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.pips { display: inline-flex; gap: 3px; }
.pips i { width: 14px; height: 4px; border-radius: 2px; background: var(--line); }
.pips i.done { background: var(--green); }
.pips i.live { background: var(--blue); }

.feed { list-style: none; margin: 0; padding: 4px 0; max-height: 560px; overflow-y: auto; }
.feed-item { display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; gap: 12px; padding: 10px 16px; cursor: pointer; align-items: start; }
.feed-item + .feed-item { border-top: 1px solid var(--line-2); }
.feed-item:hover { background: #fafbf9; }
.feed-item.fresh { animation: fresh 2.4s ease-out; }
@keyframes fresh { 0% { background: color-mix(in srgb, var(--accent) 35%, white); } 100% { background: transparent; } }
.feed-icon { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--line-2); color: var(--ink-2); }
.k-note .feed-icon, .k-voice .feed-icon { background: var(--brand-soft); color: var(--brand-dark); }
.k-photo .feed-icon { background: var(--blue-soft); color: var(--blue); }
.feed-meta { display: flex; gap: 8px; align-items: baseline; font-size: 12.5px; min-width: 0; }
.feed-meta .muted { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed-body p { font-size: 13px; margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.feed-photo { display: flex; align-items: center; gap: 10px; margin-top: 6px; font-size: 12.5px; }
.feed-photo img { width: 72px; height: 54px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); }
.feed-time { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; color: var(--ink-3); font-size: 12px; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* --- Planning ------------------------------------------------------------------------- */
.tray { margin-bottom: 14px; padding: 10px 14px 12px; transition: background .15s, border-color .15s; }
.tray.tray-drop { border: 1px dashed var(--brand); background: color-mix(in srgb, var(--brand-soft) 45%, white); }
.tray-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 8px; flex-wrap: wrap; }
.tray-head h2 { display: flex; align-items: center; gap: 8px; }
.count { display: inline-grid; place-items: center; min-width: 22px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--amber-soft); color: var(--amber); font-size: 12px; }
.tray-list { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; }
.tray-empty { padding: 4px 0 2px; }
.tcard { flex: 0 0 270px; display: flex; flex-direction: column; gap: 3px; padding: 8px 10px 9px 13px; border: 1px solid var(--line); border-radius: 9px; background: #fff; box-shadow: inset 3px 0 0 var(--tc); cursor: grab; }
.tcard:hover { border-color: #c9cec8; box-shadow: inset 3px 0 0 var(--tc), 0 4px 14px rgba(16,24,20,.08); }
.tcard.is-dragging, .pcard.is-dragging { opacity: .45; }
.tcard-head { display: flex; align-items: center; gap: 8px; }
.tcard-head a { color: var(--ink); text-decoration: none; font-size: 12.5px; }
.tcard-head a:hover { color: var(--brand); }
.drag-handle { color: var(--ink-3); display: inline-flex; margin-left: -4px; }
.tcard-title { font-weight: 700; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tcard-site { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tcard-plan { margin-left: auto; }
.plan-modal-sum { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; background: var(--line-2); border-radius: 8px; }

.plan-card { overflow: hidden; }
.plan-scroll { overflow: auto; max-height: calc(100vh - 300px); min-height: 380px; }
.plan-grid { display: grid; grid-template-columns: 196px repeat(5, minmax(150px, 1fr)); min-width: 960px; }
.plan-corner, .plan-dayhead { position: sticky; top: 0; z-index: 3; background: #fafbf9; border-bottom: 1px solid var(--line); padding: 9px 12px; }
.plan-corner { left: 0; z-index: 4; font-size: 12px; font-weight: 600; color: var(--ink-3); display: flex; align-items: flex-end; border-right: 1px solid var(--line); }
.plan-dayhead { display: flex; flex-direction: column; gap: 1px; border-left: 1px solid var(--line-2); }
.plan-dayhead b { font-size: 13.5px; }
.plan-dayhead span { font-size: 11.5px; color: var(--ink-3); }
.plan-dayhead.today { background: var(--brand-soft); box-shadow: inset 0 -2px 0 var(--brand); }
.plan-dayhead.today b, .plan-dayhead.today span { color: var(--brand-dark); }
.plan-dayhead.past b { color: var(--ink-3); }
.plan-team { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; padding: 7px 12px; background: color-mix(in srgb, var(--team) 8%, white); border-bottom: 1px solid var(--line-2); border-top: 1px solid var(--line); font-size: 12.5px; position: sticky; left: 0; }
.plan-team b { white-space: nowrap; }
.plan-team .muted { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plan-tech { position: sticky; left: 0; z-index: 2; display: flex; align-items: flex-start; gap: 9px; padding: 10px 12px; background: #fff; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line-2); box-shadow: inset 3px 0 0 var(--team); }
.plan-tech b { display: block; font-size: 13px; white-space: nowrap; }
.plan-tech small { display: block; color: var(--ink-3); font-size: 11.5px; line-height: 1.3; }
.plan-cell { display: flex; flex-direction: column; gap: 5px; padding: 6px; min-height: 76px; border-left: 1px solid var(--line-2); border-bottom: 1px solid var(--line-2); transition: background .1s; }
.plan-cell.today { background: color-mix(in srgb, var(--brand-soft) 28%, white); }
.plan-cell.past { background: #fafbfa; }
.plan-cell.over { background: color-mix(in srgb, var(--brand-soft) 70%, white); box-shadow: inset 0 0 0 2px var(--brand); }

.pcard { position: relative; padding: 5px 7px 5px 9px; border-radius: 7px; background: #fff; border: 1px solid var(--line); box-shadow: inset 3px 0 0 var(--tc); cursor: pointer; font-size: 12px; line-height: 1.3; min-width: 0; }
.pcard.movable { cursor: grab; }
.pcard:hover { border-color: #bfc6bf; box-shadow: inset 3px 0 0 var(--tc), 0 3px 10px rgba(16,24,20,.08); z-index: 1; }
.pcard-top { display: flex; align-items: center; gap: 5px; }
.pcard-top b { font-size: 11.5px; }
.pcard-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pcard-site { color: var(--ink-3); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pstat { margin-left: auto; padding: 0 6px; border-radius: 9px; font-size: 10.5px; font-weight: 700; white-space: nowrap; line-height: 16px; }
.pstat.live { box-shadow: 0 0 0 2px color-mix(in srgb, var(--blue) 25%, transparent); }
.urgent-dot { display: inline-flex; color: var(--red); }
.pcard.st-termine, .pcard.st-rapport_valide, .pcard.st-facture { background: #fbfbfa; }
.pcard.st-termine .pcard-title, .pcard.st-rapport_valide .pcard-title, .pcard.st-facture .pcard-title { color: var(--ink-2); }
.pcard.st-en_route, .pcard.st-sur_place { border-color: color-mix(in srgb, var(--blue) 45%, white); }

/* --- Demandes entrantes (boîte de réception) -------------------------------------------- */
.mailbox { display: grid; grid-template-columns: 340px minmax(0, 1fr); min-height: calc(100vh - 210px); overflow: hidden; }
.mail-list { border-right: 1px solid var(--line); overflow-y: auto; max-height: calc(100vh - 210px); }
.mail-tabs { position: sticky; top: 0; z-index: 1; display: flex; gap: 2px; padding: 8px; background: #fafbf9; border-bottom: 1px solid var(--line); }
.mail-tabs button { flex: 1; border: 0; background: none; padding: 6px 8px; border-radius: 7px; font-weight: 600; font-size: 12.5px; color: var(--ink-2); cursor: pointer; }
.mail-tabs button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.mail-tabs em { font-style: normal; background: var(--red); color: #fff; border-radius: 9px; padding: 0 6px; font-size: 11px; }
.mail-item { display: block; padding: 11px 14px 11px 16px; border-bottom: 1px solid var(--line-2); text-decoration: none; position: relative; }
.mail-item:hover { background: #fafbf9; }
.mail-item.active { background: color-mix(in srgb, var(--brand-soft) 55%, white); box-shadow: inset 3px 0 0 var(--brand); }
.mi-top { display: flex; align-items: center; gap: 8px; }
.mi-from { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 600; }
.mail-item.unread .mi-from { font-weight: 800; }
.mi-time { color: var(--ink-3); font-size: 12px; white-space: nowrap; }
.mail-item.unread .mi-time { color: var(--brand); font-weight: 700; }
.mi-subject { margin-top: 3px; font-size: 13px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-item.unread .mi-subject { color: var(--ink); font-weight: 700; }
.mi-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 4px; font-size: 12px; }
.mi-foot .muted { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mi-done { display: inline-flex; align-items: center; gap: 3px; color: var(--green); font-weight: 700; white-space: nowrap; }
.unread-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand); flex: none; }
.chan-ic { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; flex: none; }
.chan-mail { background: var(--blue-soft); color: var(--blue); }
.chan-tel { background: var(--amber-soft); color: var(--amber); }
.chan-web { background: var(--green-soft); color: var(--green); }
.mail-pane { overflow-y: auto; max-height: calc(100vh - 210px); min-width: 0; }
.mail-back { display: none; margin: 12px 16px 0; }
.mail-read { padding: 22px 26px 28px; }
.mail-head h2 { font-size: 19px; line-height: 1.3; }
.mail-from { display: flex; align-items: center; gap: 12px; margin-top: 14px; padding-bottom: 16px; border-bottom: 1px solid var(--line-2); }
.mail-avatar { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-dark); font-weight: 800; flex: none; }
.mail-when { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.chan { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.mail-text { white-space: pre-line; padding: 18px 0; line-height: 1.6; font-size: 14px; max-width: 72ch; }
.call-note { margin-bottom: 8px; font-style: italic; }
.mail-actions { display: flex; align-items: center; gap: 14px; padding-top: 16px; border-top: 1px solid var(--line-2); flex-wrap: wrap; }
.mail-form { padding-top: 16px; border-top: 1px solid var(--line-2); }
.done-box { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 10px; background: var(--green-soft); border: 1px solid color-mix(in srgb, var(--green) 25%, white); flex-wrap: wrap; }
.done-box b { display: block; }
.done-box .grow > span { display: flex; align-items: center; gap: 8px; color: var(--ink-2); font-size: 13px; flex-wrap: wrap; }
.done-icon { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--green); color: #fff; flex: none; }
.quoted { white-space: pre-line; padding: 10px 14px; border-left: 3px solid var(--line); background: #fafbf9; border-radius: 0 8px 8px 0; color: var(--ink-2); font-size: 13px; max-height: 160px; overflow-y: auto; }

/* --- Formulaire d'intervention ----------------------------------------------------------- */
.iform { display: flex; flex-direction: column; gap: 14px; }
.prepared { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 10px; background: var(--brand-soft); color: var(--brand-dark); }
.prepared b { display: block; }
.prepared span:not(.prepared-icon) { font-size: 13px; }
.prepared-icon { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: var(--brand); color: #fff; flex: none; }
.toggle { display: flex; align-items: center; gap: 8px; align-self: end; height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; font-weight: 600; color: var(--ink-2); background: #fff; }
.toggle input { accent-color: var(--red); width: 16px; height: 16px; margin: 0; }
.toggle.on { border-color: color-mix(in srgb, var(--red) 40%, white); background: var(--red-soft); color: var(--red); }
.plan-box { border: 1px solid var(--line); border-radius: 10px; padding: 14px; margin: 0; display: flex; flex-direction: column; gap: 12px; background: #fcfdfc; }
.seg-choice { display: inline-flex; gap: 4px; padding: 3px; border-radius: 9px; background: var(--line-2); align-self: flex-start; flex-wrap: wrap; }
.seg-choice button { display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; padding: 6px 12px; border-radius: 7px; font-weight: 600; font-size: 13px; color: var(--ink-2); cursor: pointer; }
.seg-choice button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.1); }
.form-foot { display: flex; justify-content: flex-end; gap: 8px; }

/* --- Fil terrain, rapport --------------------------------------------------------------- */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ''; position: absolute; left: 15px; top: 8px; bottom: 8px; width: 2px; background: var(--line-2); }
.tl-day { position: relative; padding: 4px 0 8px 44px; font-size: 12px; font-weight: 700; color: var(--ink-3); text-transform: uppercase; letter-spacing: .04em; }
.tl { position: relative; display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: 12px; padding-bottom: 14px; }
.tl-icon { position: relative; display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: #fff; border: 2px solid var(--line); color: var(--ink-2); }
.tl-status .tl-icon { border-color: color-mix(in srgb, var(--blue) 40%, white); color: var(--blue); }
.tl-note .tl-icon, .tl-voice .tl-icon { border-color: color-mix(in srgb, var(--brand) 40%, white); color: var(--brand); }
.tl-photo .tl-icon { border-color: color-mix(in srgb, var(--violet) 40%, white); color: var(--violet); }
.tl-body { padding-top: 5px; min-width: 0; }
.tl-meta { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; }
.tl-meta span { color: var(--ink-3); font-size: 12px; white-space: nowrap; }
.tl-body p { margin-top: 3px; }
.tl-note .tl-body p, .tl-voice .tl-body p { padding: 8px 11px; background: #fafbf9; border: 1px solid var(--line-2); border-radius: 8px; margin-top: 6px; }
.tl-photo button { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; padding: 0; border: 0; background: none; cursor: zoom-in; text-align: left; color: var(--ink-3); font-size: 12px; }
.tl-photo img { width: 220px; max-width: 100%; height: 150px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.note-add { display: flex; gap: 8px; margin-top: 6px; padding-top: 14px; border-top: 1px solid var(--line-2); }
.zoom { width: 100%; height: auto; border-radius: 8px; display: block; }
.rsec + .rsec { margin-top: 14px; }
.rsec h3 { font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--brand); margin-bottom: 4px; }
.report-foot { display: flex; flex-direction: column; gap: 6px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line-2); }
.kv-row { display: flex; align-items: center; gap: 10px; }
.kv-row > span:first-child { color: var(--ink-3); min-width: 110px; font-size: 13px; }
.report-actions { display: flex; align-items: center; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.report-actions:empty { display: none; }

/* --- Lignes de devis et de facture ------------------------------------------------------- */
.lines-table { min-width: 640px; }
.lines-table td { vertical-align: middle; }
.line-label { display: block; font-weight: 600; }
.lines-table small { font-size: 11.5px; }
.qty { width: 74px; padding: 6px 8px; text-align: right; display: inline-block; }
.lines-add { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line-2); color: var(--brand); }
.lines-add select { max-width: 560px; }
.totals { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; padding: 14px 16px 16px; border-top: 1px solid var(--line-2); }
.totals div { display: grid; grid-template-columns: 120px 120px; text-align: right; gap: 12px; color: var(--ink-2); }
.totals .grand { margin-top: 6px; padding-top: 8px; border-top: 1px solid var(--line); color: var(--ink); font-size: 16px; }

/* --- Contrats, résultats ------------------------------------------------------------------ */
.next-visit small { font-size: 12px; margin-top: 2px; }
.result-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.result-list li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line-2); color: var(--green); flex-wrap: wrap; }
.result-list a { color: var(--ink); font-weight: 600; text-decoration: none; }
.result-list a:hover { color: var(--brand); }
.result-list .muted { font-size: 12.5px; margin-left: auto; }

/* --- Mail simulé -------------------------------------------------------------------------- */
.mail-compose { display: flex; flex-direction: column; gap: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.mc-row { display: flex; gap: 12px; align-items: baseline; padding: 9px 14px; border-bottom: 1px solid var(--line-2); font-size: 13.5px; }
.mc-row > span:first-child { width: 44px; color: var(--ink-3); font-size: 12.5px; flex: none; }
.mc-body { border: 0 !important; border-radius: 0 !important; box-shadow: none !important; min-height: 200px; padding: 14px; }
.attachment { display: flex; align-items: center; gap: 12px; margin: 0 14px 14px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; text-decoration: none; background: #fafbf9; max-width: 360px; color: var(--ink-3); }
.attachment:hover { border-color: var(--brand); }
.attachment b { display: block; color: var(--ink); font-size: 13px; }
.attachment small { color: var(--ink-3); font-size: 12px; }
.attachment > span:nth-child(2) { flex: 1; }
.att-icon { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 8px; background: var(--red-soft); color: var(--red); }

/* --- Accueil et visite guidée (profile.welcome) ---------------------------------------- */
.guide { position: fixed; inset: 0; z-index: 60; overflow-y: auto; background: var(--bg); }
.guide .link { background: none; border: 0; padding: 0; font: inherit; color: var(--brand-dark); text-decoration: underline; cursor: pointer; }
.guide-banner { background: #1d2420; color: #e9ece9; font-size: 12px; text-align: center; padding: 8px 16px; }
.guide-body { max-width: 560px; margin: 0 auto; padding: 28px 20px 40px; display: flex; flex-direction: column; gap: 20px; }
.guide-logo { width: 170px; height: 64px; object-fit: contain; object-position: left center; }
.guide-intro { display: flex; flex-direction: column; gap: 10px; }
.guide-intro h1 { font-size: 25px; line-height: 1.25; letter-spacing: -.01em; }
.guide-intro p { font-size: 15px; line-height: 1.5; color: var(--ink-2); }
.guide-eyebrow { font-size: 13px; font-weight: 600; color: var(--brand); }
.guide-card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.guide-card h2 { font-size: 17px; line-height: 1.35; }
.guide-card h2.guide-eyebrow { font-size: 13px; }
.guide-card ul { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; font-size: 14px; line-height: 1.5; }
.guide-question { display: flex; flex-direction: column; gap: 12px; }
.guide-question h2 { font-size: 19px; line-height: 1.3; }
.guide-choices { display: flex; flex-direction: column; gap: 10px; }
.guide-choice { display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 12px 14px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; text-align: left; font: inherit; color: var(--ink); cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.guide-choice:hover, .guide-choice:focus-visible { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); outline: none; }
.guide-choice b { display: block; font-size: 15px; font-weight: 600; }
.guide-choice small { display: block; margin-top: 2px; font-size: 13px; color: var(--ink-2); }
.guide-choice > .icon:last-child { flex: none; color: var(--ink-3); }
.guide-choice-icon { flex: none; display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; background: var(--brand-soft); color: var(--brand-dark); }
.guide-other { display: flex; flex-direction: column; gap: 6px; }
.guide-other label { font-size: 14px; font-weight: 600; }
.guide-other-row { display: flex; gap: 8px; }
.guide-other-row .input { flex: 1; min-width: 0; min-height: 46px; font-size: 15px; }
.guide-other-row .btn { min-height: 46px; }
.guide-foot { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
.guide-foot p { font-size: 12.5px; line-height: 1.5; color: var(--ink-3); }
.guide-all { min-height: 44px; font-size: 15px; font-weight: 600; }
.guide-outcome { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.guide-outcome li { display: flex; gap: 12px; align-items: flex-start; font-size: 15px; line-height: 1.45; }
.guide-outcome li > span { flex: none; display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 13px; background: var(--brand-soft); color: var(--brand-dark); font-size: 13px; font-weight: 700; }
.guide-verdicts { display: flex; flex-direction: column; gap: 8px; }
.guide-verdict { min-height: 46px; padding: 0 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); font: inherit; font-size: 15px; text-align: left; color: var(--ink); cursor: pointer; }
.guide-verdict:hover { border-color: var(--brand); }
.guide-verdict.on { border: 2px solid var(--brand); background: var(--brand-soft); font-weight: 600; }
.guide-thanks { display: flex; align-items: center; gap: 8px; color: var(--green); font-weight: 600; }
.guide-contact { display: flex; flex-direction: column; gap: 8px; }
.guide-contact p { text-align: center; font-size: 13.5px; color: var(--ink-2); }
.guide-contact p a { color: var(--brand-dark); }
.guide-call { min-height: 50px; font-size: 15px; white-space: normal; text-align: center; }
.guide-links { display: flex; justify-content: space-between; gap: 12px; }
.guide-links .link { min-height: 44px; font-size: 15px; font-weight: 600; }

.tour-sheet { position: fixed; z-index: 55; right: 24px; bottom: 24px; width: min(400px, calc(100vw - 32px)); display: flex; flex-direction: column; gap: 10px; padding: 18px 20px 16px; background: var(--panel); border-radius: 16px; box-shadow: 0 12px 40px rgba(16, 24, 20, .22); }
.tour-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 13px; font-weight: 600; color: var(--brand); }
.tour-dots { display: inline-flex; gap: 6px; }
.tour-dots i { width: 6px; height: 6px; border-radius: 3px; background: var(--line); }
.tour-dots i.on { width: 22px; background: var(--brand); }
.tour-sheet h2 { font-size: 18px; line-height: 1.3; }
.tour-sheet p { font-size: 14.5px; line-height: 1.5; color: var(--ink-2); }
.tour-actions { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.tour-actions .btn { min-height: 44px; }
.tour-stop { margin-left: auto; min-height: 44px; padding: 0; border: 0; background: none; font: inherit; color: var(--ink-2); text-decoration: underline; cursor: pointer; }
.tour-target { position: relative; z-index: 1; box-shadow: 0 0 0 3px var(--panel), 0 0 0 6px var(--brand) !important; animation: tour-pulse 1.6s ease-in-out infinite; }
@keyframes tour-pulse { 50% { box-shadow: 0 0 0 3px var(--panel), 0 0 0 10px color-mix(in srgb, var(--brand) 30%, transparent) !important; } }
@media (prefers-reduced-motion: reduce) { .tour-target { animation: none; } }
html.touring .main { padding-bottom: 320px; }

/* --- Écrans étroits --------------------------------------------------------------------- */
@media (max-width: 1280px) {
  .detail-grid { grid-template-columns: minmax(0, 1fr) 300px; }
  .frow { grid-template-columns: 34px 120px minmax(0, 1fr) auto; }
}
@media (max-width: 1100px) {
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash-grid, .detail-grid { grid-template-columns: minmax(0, 1fr); }
  .legend { margin-left: 0; }
}
@media (max-width: 860px) {
  .mailbox { grid-template-columns: 1fr; min-height: 0; }
  .mail-list, .mail-pane { max-height: none; border-right: 0; }
  .mailbox.has-selection .mail-list { display: none; }
  .mailbox:not(.has-selection) .mail-pane { display: none; }
  .mail-back { display: inline-flex; }
  .mail-read { padding: 16px; }
  .search { margin-left: 0; min-width: 0; width: 100%; }
  .frow { grid-template-columns: 34px minmax(0, 1fr) auto; }
  .frow-what { grid-column: 2 / -1; grid-row: 2; }
  .plan-scroll { max-height: none; }
  .totals div { grid-template-columns: 100px 110px; }
}
/* Téléphone : chaque ligne de tableau devient une fiche (plus de défilement de côté). Les cellules
   nues (chiffres, dates) gardent le nom de leur colonne, posé par ui.js dans data-label. */
@media (max-width: 640px) {
  /* Titre et boutons d'un en-tête de carte : les boutons passent dessous plutôt que de déborder. */
  .card-head { flex-wrap: wrap; }
  .tour-sheet { left: 0; right: 0; bottom: 0; width: auto; border-radius: 20px 20px 0 0; padding: 18px 18px calc(16px + env(safe-area-inset-bottom)); }
  .toolbar .search { flex: 1 1 100%; margin-left: 0; min-width: 0; }
  .toolbar .input.auto { flex: 1 1 calc(50% - 5px); min-width: 0; }
  .table-wrap .table { min-width: 0; }
  .table, .table tbody { display: block; }
  .table thead { display: none; }
  .table tr { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; padding: 12px 16px; border-bottom: 1px solid var(--line-2); }
  .table tbody tr:last-child { border-bottom: 0; }
  .table td, .table.compact td { display: block; padding: 0; border: 0; max-width: 100%; min-width: 0; text-align: left; }
  .table td:has(> b), .table td.clip { flex-basis: 100%; max-width: 100%; }
  .table td:last-child:not(:first-child) { margin-left: auto; }
  .table td.is-empty { display: none; }
  .table td[data-label].right::before,
  .table td[data-label].nowrap:not(:first-child):not(:has(small.block, .avatar, .badge, .row))::before { content: attr(data-label) " "; color: var(--ink-3); font-weight: 400; font-size: 12px; }
  .table tr.row-alert { box-shadow: inset 3px 0 0 var(--red); }
  .table tr.row-alert td:first-child { box-shadow: none; }
}
@media (max-width: 520px) {
  .tiles { grid-template-columns: 1fr 1fr; gap: 8px; }
  .tile { padding: 12px; }
  .tile-value { font-size: 24px; }
  .toolbar .input.auto { flex: 1 1 calc(50% - 5px); min-width: 0; }
}

/* --- Documents A4 (rapport, devis, facture) ------------------------------------------------ */
body.doc-body { background: #e9ece8; }
.doc-wrap { min-height: 100vh; padding: 0 16px 40px; }
.doc-toolbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 12px; max-width: 210mm; margin: 0 auto; padding: 12px 0; background: #e9ece8; flex-wrap: wrap; }
.doc-page { position: relative; width: 210mm; max-width: 100%; min-height: 297mm; margin: 0 auto; padding: 16mm 15mm 22mm; background: #fff; box-shadow: 0 6px 30px rgba(0,0,0,.12); font-size: 12.5px; color: #1d2420; display: flex; flex-direction: column; gap: 16px; }
.doc-bar { position: absolute; left: 0; right: 0; top: 0; height: 6px; background: linear-gradient(90deg, var(--brand), var(--accent)); }
.doc-head { display: flex; justify-content: space-between; gap: 24px; align-items: flex-start; }
.doc-company { display: flex; gap: 14px; align-items: flex-start; }
.doc-company img { width: 70px; height: auto; }
.doc-company div { display: flex; flex-direction: column; color: var(--ink-2); font-size: 12px; }
.doc-company b { color: var(--brand-dark); font-size: 15px; margin-bottom: 2px; }
.doc-title { text-align: right; display: flex; flex-direction: column; gap: 2px; align-items: flex-end; }
.doc-title h1 { font-size: 22px; color: var(--brand-dark); text-transform: uppercase; letter-spacing: .03em; }
.doc-number { font-size: 15px; font-weight: 700; margin-bottom: 6px; }
.doc-meta { display: flex; gap: 10px; font-size: 12px; }
.doc-meta span { color: var(--ink-3); }
.doc-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.doc-box { display: flex; flex-direction: column; gap: 1px; padding: 11px 13px; border: 1px solid var(--line); border-radius: 8px; }
.doc-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--brand); font-weight: 700; margin-bottom: 3px; }
.doc-strip { display: grid; grid-template-columns: auto 1fr auto; gap: 18px; padding: 10px 13px; border-radius: 8px; background: color-mix(in srgb, var(--brand-soft) 55%, white); }
.doc-strip > div { display: flex; flex-direction: column; }
.outcome-resolu { color: var(--green); }
.outcome-a_suivre { color: var(--amber); }
.outcome-non_resolu { color: var(--red); }
.doc-equipment { padding: 0 2px; color: var(--ink-2); }
.doc-equipment .doc-label { display: block; }
.doc-values { width: 100%; border-collapse: collapse; }
.doc-values th { text-align: left; font-weight: 400; color: var(--ink-2); padding: 5px 9px 5px 0; border-bottom: 1px solid var(--line-2); width: 60%; }
.doc-values td { padding: 5px 0; border-bottom: 1px solid var(--line-2); font-weight: 700; }
.doc-values td.ok { color: var(--green); }
.doc-values td.ko { color: var(--ink-3); font-weight: 400; }
.doc-values td svg { vertical-align: -2px; }
.doc-legal { font-size: 10.5px; line-height: 1.5; color: var(--ink-3); border-left: 3px solid var(--brand-soft); padding-left: 9px; break-inside: avoid; }
.doc-section h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--brand-dark); padding-bottom: 4px; margin-bottom: 6px; border-bottom: 2px solid var(--brand-soft); }
.doc-section p { line-height: 1.6; white-space: pre-line; }
.doc-photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.doc-photos figure { margin: 0; }
.doc-photos img { width: 100%; height: 42mm; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); display: block; }
.doc-photos figcaption { font-size: 10.5px; color: var(--ink-3); margin-top: 3px; }
.doc-sign { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 4px; break-inside: avoid; }
.doc-sign .sig { max-height: 26mm; max-width: 100%; object-fit: contain; align-self: flex-start; margin: 4px 0; }
.sig-blank { display: block; height: 20mm; }
.sig-blank.tall { height: 26mm; border: 1px dashed var(--line); border-radius: 6px; margin-top: 6px; }
.doc-terms span { color: var(--ink-2); }
.accord-ok { color: var(--green); font-size: 14px; }
.doc-lines { width: 100%; border-collapse: collapse; }
.doc-lines th { text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; color: #fff; background: var(--brand); padding: 7px 9px; }
.doc-lines th.right, .doc-lines td.right { text-align: right; }
.doc-lines td { padding: 8px 9px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
.doc-lines td small { display: block; color: var(--ink-3); font-size: 10.5px; }
.doc-lines tr:nth-child(even) td { background: #fafbf9; }
.doc-totals { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; break-inside: avoid; }
.doc-totals div { display: grid; grid-template-columns: 110px 110px; gap: 10px; text-align: right; }
.doc-totals .grand { margin-top: 4px; padding: 7px 9px; background: var(--brand-soft); color: var(--brand-dark); border-radius: 6px; font-size: 14px; }
.doc-pay { display: flex; flex-direction: column; gap: 4px; padding: 11px 13px; border: 1px solid var(--line); border-radius: 8px; break-inside: avoid; }
.doc-foot { position: absolute; left: 15mm; right: 15mm; bottom: 9mm; text-align: center; font-size: 10.5px; color: var(--ink-3); border-top: 1px solid var(--line-2); padding-top: 6px; }

/* Compte rendu de période : chiffres, détail chronologique, vignettes */
.digest-contract { grid-template-columns: 1fr auto; }
.digest-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(112px, 1fr)); gap: 8px; }
.digest-stat { display: flex; flex-direction: column; gap: 1px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; break-inside: avoid; }
.digest-stat span { font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); font-weight: 700; }
.digest-stat b { font-size: 19px; color: var(--brand-dark); }
.digest-stat small { font-size: 10.5px; color: var(--ink-3); }
.digest-stat.is-green b { color: var(--green); }
.digest-stat.is-amber b { color: var(--amber); }
.digest-next { margin-top: 7px; font-size: 12px; color: var(--ink-2); }
.digest-drafting { font-style: italic; }
.digest-list { width: 100%; border-collapse: collapse; font-size: 11.5px; }
.digest-list th { text-align: left; font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: #fff; background: var(--brand); padding: 6px 7px; }
.digest-list td { padding: 7px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
.digest-list tr { break-inside: avoid; }
.digest-list tr:nth-child(even) td { background: #fafbf9; }
.digest-list td small { display: block; color: var(--ink-3); font-size: 10.5px; margin-top: 1px; }
.digest-list td small a { color: inherit; }
.digest-list small.digest-type { color: var(--brand); font-weight: 700; }
.digest-issue { color: var(--amber); }
.digest-title { display: block; margin-bottom: 2px; }
.digest-thumbs { display: flex; gap: 6px; margin-top: 5px; }
.digest-thumbs img { width: 64px; height: 48px; object-fit: cover; border-radius: 5px; border: 1px solid var(--line); display: block; }
/* Dans le CRM : période, destinataire et aperçu A4 */
.digest-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.digest-to { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; }
.digest-preview { background: #e9ece8; border-radius: 12px; padding: 18px; overflow-x: auto; }
.digest-preview .doc-page { min-height: 0; }
.chip:disabled { opacity: .45; cursor: not-allowed; }
.digest-table .group-row td { background: var(--line-2); padding: 8px 12px; cursor: default; }
.digest-table .group-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.digest-table td.digest-site { padding-left: 22px; }

@media (max-width: 820px) {
  .doc-page { width: 100%; min-height: 0; padding: 22px 18px 50px; }
  .doc-head, .doc-company { flex-direction: column; }
  .doc-title { text-align: left; align-items: flex-start; }
  .doc-parties, .doc-sign { grid-template-columns: 1fr; }
  .doc-strip { grid-template-columns: 1fr; gap: 8px; }
  .doc-photos { grid-template-columns: 1fr 1fr; }
  .doc-lines { font-size: 11.5px; }
  .doc-lines th { letter-spacing: 0; padding: 6px 5px; }
  .doc-lines td { padding: 7px 5px; }
  .doc-foot { left: 18px; right: 18px; bottom: 14px; }
  .digest-contract { grid-template-columns: 1fr; }
  .digest-list thead { display: none; }
  .digest-list tr { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; padding: 9px 0; border-bottom: 1px solid var(--line-2); }
  .digest-list td { border: 0; padding: 0; background: none !important; }
  .digest-list td:nth-child(n+3) { grid-column: 1 / -1; }
  .digest-preview { padding: 0; background: none; }
}

@media print {
  @page { size: A4; margin: 0; }
  body.doc-body { background: #fff; }
  .doc-toolbar, .demo-banner, #toast { display: none !important; }
  .doc-wrap { padding: 0; }
  .doc-page { box-shadow: none; width: 210mm; min-height: 297mm; margin: 0; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* --- Champs : hauteur commune, flèche des listes ---------------------------------------- */
.crm select.input, .modal select.input { -webkit-appearance: none; appearance: none; height: 38px; padding: 0 32px 0 11px; cursor: pointer;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%237c8580' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 11px center; text-overflow: ellipsis; }
.crm input.input:not([type=checkbox]), .modal input.input:not([type=checkbox]) { height: 38px; }
.crm input.input.qty { height: 32px; }
.tcard-head a { white-space: nowrap; }
.lines-table .unit { display: inline-block; min-width: 58px; margin-left: 7px; text-align: left; }
.table td.num, .table td.nowrap { white-space: nowrap; }
@media (max-width: 520px) {
  .stats { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat { padding: 12px; }
  .stat b { font-size: 18px; }
  .page-head h1 { font-size: 20px; }
}

/* --- Chantiers (pose en équipe, dossier administratif) ------------------------------------ */
.type-pose { --tc: var(--t-pose); }
.steps-mini { display: inline-flex; gap: 3px; }
.steps-mini i { width: 14px; height: 6px; border-radius: 3px; background: var(--line); }
.steps-mini i.done { background: var(--green); }
.steps-mini i.now { background: var(--brand); }
.steps-mini i.late { background: var(--red); }
.pstepper { list-style: none; margin: 0; padding: 6px 18px 14px; }
.pstep { position: relative; display: flex; gap: 14px; padding: 10px 0; }
.pstep:not(:last-child)::before { content: ''; position: absolute; left: 13px; top: 38px; bottom: -6px; width: 2px; background: var(--line); }
.pstep.done:not(:last-child)::before { background: var(--green); }
.pstep-dot { flex: none; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--line); background: var(--panel); color: var(--ink-3); font-weight: 700; font-size: 12px; z-index: 1; }
.pstep.done .pstep-dot { background: var(--green); border-color: var(--green); color: #fff; }
.pstep.now .pstep-dot { border-color: var(--brand); color: var(--brand-dark); box-shadow: 0 0 0 4px var(--brand-soft); }
.pstep.late .pstep-dot { border-color: var(--red); color: var(--red); box-shadow: 0 0 0 4px var(--red-soft); }
.pstep-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; padding-top: 3px; }
.pstep-top { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.pstep:not(.done):not(.now) .pstep-top b { color: var(--ink-3); font-weight: 600; }
.pstep-party { font-size: 11.5px; font-weight: 700; padding: 1px 7px; border-radius: 6px; background: var(--line-2); color: var(--ink-2); }
.pstep-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.crew-line { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line-2); font-size: 13px; }
.crew-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; margin-top: 6px; }
.crew-chip { display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); text-align: left; cursor: pointer; font: inherit; }
.crew-chip small { display: block; color: var(--ink-3); font-size: 11.5px; }
.crew-chip.on { border-color: var(--brand); background: var(--brand-soft); box-shadow: inset 0 0 0 1px var(--brand); }
.crew-chip.busy:not(.on) { opacity: .55; }
.avatars { display: inline-flex; }
.avatars .avatar + .avatar { margin-left: -6px; box-shadow: 0 0 0 2px var(--panel); }
.hint.warn { color: var(--amber); display: flex; gap: 6px; align-items: flex-start; }
