:root {
  --bg: #f5f4f1;
  --card: #ffffff;
  --ink: #1b1a18;
  --muted: #6f6a63;
  --light: #9b958c;
  --border: #e4e0d8;
  --border-strong: #cfc9bf;
  --soft: #faf9f7;
  --accent: #e85d22;
  --accent-dk: #b8471a;
  --accent-bg: #fbeee6;
  --side: #1b1a18;
  --ok: #2f7d4f;
  --ok-bg: #e5f3ea;
  --warn: #9a6200;
  --warn-bg: #fdf2dc;
  --err: #b42318;
  --err-bg: #fdecea;
  --info: #2458a6;
  --info-bg: #e8effb;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(27, 26, 24, 0.06), 0 1px 1px rgba(27, 26, 24, 0.04);
  --font: Inter, system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); font-size: 14px; color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
.boot { padding: 40px; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pre { white-space: pre-line; }
.mt { margin-top: 16px; }

/* ---------- Structure ---------- */
.layout { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.side { background: var(--side); color: #d9d5ce; padding: 18px 12px; display: flex; flex-direction: column; gap: 3px; position: sticky; top: 0; height: 100vh; height: 100dvh; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: #3a3632 transparent; }
.side > * { flex-shrink: 0; }
.side .brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; }
.side .brand img { width: 96px; background: #fff; border-radius: 6px; padding: 4px 6px; }
.side .brand span { font-weight: 700; letter-spacing: 0.12em; font-size: 12px; color: var(--accent); }
.side .sect { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: #8a847b; padding: 14px 10px 6px; }
.side a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; text-decoration: none; color: #d9d5ce; font-weight: 500; }
.side a:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.side a.on { background: rgba(232, 93, 34, 0.16); color: #fff; }
.side a.on .ic { color: var(--accent); }
.side a .cnt { margin-left: auto; background: var(--accent); color: #fff; border-radius: 10px; font-size: 11px; font-weight: 700; padding: 1px 7px; }
.side .ic { width: 18px; height: 18px; flex: none; }
.side .grow { flex: 1 0 8px; }
@media (max-height: 720px) {
  .side { padding-top: 12px; }
  .side .brand { padding-bottom: 10px; }
  .side .sect { padding-top: 10px; }
  .side a { padding-top: 6px; padding-bottom: 6px; }
}
.side .me { border-top: 1px solid rgba(255, 255, 255, 0.08); padding: 12px 10px 0; font-size: 13px; }
.side .me b { display: block; color: #fff; }
.side .me span { color: #8a847b; font-size: 12px; }
.side .me button { margin-top: 8px; background: none; border: 1px solid rgba(255, 255, 255, 0.15); color: #d9d5ce; border-radius: 7px; padding: 5px 10px; cursor: pointer; font-size: 12px; }
.main { min-width: 0; }
.scrim { display: none; }
.topbar { display: none; }
.page { padding: 24px 28px 70px; max-width: 1320px; }
.page.wide { max-width: none; }
.ph { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.ph h1 { font-size: 22px; margin: 0; letter-spacing: -0.01em; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ph .sub { color: var(--muted); margin-top: 3px; }
.crumb { color: var(--muted); font-size: 13px; margin-bottom: 6px; display: inline-flex; align-items: center; gap: 4px; text-decoration: none; }
.crumb:hover { color: var(--ink); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }

/* ---------- Composants ---------- */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-h { padding: 13px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.card-h h3 { margin: 0; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.card-h h3 .ic { color: var(--accent); }
.card-b { padding: 16px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--border-strong); background: #fff; border-radius: 8px; padding: 8px 14px; cursor: pointer; font-weight: 500; white-space: nowrap; text-decoration: none; min-height: 36px; }
.btn:hover { background: var(--soft); border-color: #bdb6aa; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.pri { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.pri:hover { background: var(--accent-dk); border-color: var(--accent-dk); }
.btn.dark { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.danger { color: var(--err); }
.btn.danger:hover { background: var(--err-bg); border-color: #f3b8b2; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: rgba(0, 0, 0, 0.04); }
.btn.sm { padding: 4px 10px; min-height: 30px; font-size: 13px; }
.btn.lg { padding: 11px 18px; min-height: 46px; font-size: 15px; font-weight: 600; }
.btn.icon { padding: 6px; min-height: 32px; min-width: 32px; }
.btn svg { width: 16px; height: 16px; }

label.f { display: block; }
label.f > span { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.in, select.in, textarea.in { width: 100%; border: 1px solid var(--border-strong); background: #fff; border-radius: 8px; padding: 8px 10px; min-height: 36px; outline: none; }
textarea.in { resize: vertical; min-height: 64px; line-height: 1.45; }
.in:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(232, 93, 34, 0.15); }
.in:disabled, textarea.in:disabled, select.in:disabled { background: #f7f6f3; color: var(--muted); }
.in.num { text-align: right; font-variant-numeric: tabular-nums; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px 12px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px 12px; }
.span2 { grid-column: span 2; }
.span3 { grid-column: span 3; }
.full { grid-column: 1 / -1; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.check input { width: 17px; height: 17px; accent-color: var(--accent); }
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 8px; overflow: hidden; background: #fff; }
.seg button { border: 0; background: #fff; padding: 7px 12px; cursor: pointer; font-weight: 500; display: inline-flex; align-items: center; gap: 6px; }
.seg button + button { border-left: 1px solid var(--border-strong); }
.seg button.on { background: var(--ink); color: #fff; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filters .in { width: auto; }
.filters .grow { flex: 1 1 220px; max-width: 360px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; scrollbar-width: none; }
.tabs button { border: 0; background: none; padding: 10px 12px; cursor: pointer; font-weight: 500; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.tabs button.on { color: var(--ink); border-bottom-color: var(--accent); }
.tabs .n { font-size: 11px; background: #eeebe6; border-radius: 10px; padding: 1px 7px; }
.tabs button.on .n { background: var(--accent-bg); color: var(--accent-dk); }

table.t { width: 100%; border-collapse: collapse; }
table.t th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--border); background: var(--soft); white-space: nowrap; }
table.t td { padding: 10px 12px; border-bottom: 1px solid #efece7; vertical-align: middle; }
table.t tr:last-child td { border-bottom: 0; }
table.t tr.click { cursor: pointer; }
table.t tr.click:hover td { background: #faf8f5; }
table.t .r { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.t .muted { color: var(--muted); }
table.t .sub { display: block; color: var(--muted); font-size: 12px; margin-top: 1px; }
.tbl-wrap { overflow-x: auto; }
.empty { padding: 34px 16px; text-align: center; color: var(--muted); }
.empty .ic { width: 28px; height: 28px; color: var(--light); display: block; margin: 0 auto 8px; }

.pill { display: inline-flex; align-items: center; gap: 5px; border-radius: 20px; padding: 2px 9px; font-size: 12px; font-weight: 600; white-space: nowrap; line-height: 1.5; }
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.p-grey { background: #efece7; color: #6f6a63; }
.p-blue { background: var(--info-bg); color: var(--info); }
.p-orange { background: var(--accent-bg); color: var(--accent-dk); }
.p-yellow { background: var(--warn-bg); color: var(--warn); }
.p-green { background: var(--ok-bg); color: var(--ok); }
.p-red { background: var(--err-bg); color: var(--err); }
.p-dark { background: #2c2925; color: #fff; }
.tag { display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase; color: var(--accent-dk); background: var(--accent-bg); border-radius: 5px; padding: 2px 6px; white-space: nowrap; }
.tag.grey { color: var(--muted); background: #efece7; }
.tag.plain { text-transform: none; letter-spacing: 0; font-size: 12px; font-weight: 600; padding: 3px 8px; }
.code { font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: 0.01em; }
.neg { color: var(--err); font-weight: 700; }

/* ---------- Tableau de bord ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 18px; }
.kpi { padding: 14px 16px; display: flex; gap: 12px; align-items: flex-start; text-decoration: none; }
a.kpi:hover { border-color: var(--accent); }
.kpi .ico { width: 38px; height: 38px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex: none; background: var(--accent-bg); color: var(--accent); }
.kpi .ico .ic { width: 20px; height: 20px; }
.kpi .ico.red { background: var(--err-bg); color: var(--err); }
.kpi .ico.green { background: var(--ok-bg); color: var(--ok); }
.kpi .ico.blue { background: var(--info-bg); color: var(--info); }
.kpi .ico.yellow { background: var(--warn-bg); color: var(--warn); }
.kpi .l { color: var(--muted); font-size: 12px; font-weight: 600; }
.kpi .v { font-size: 24px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; line-height: 1.2; }
.kpi .s { color: var(--light); font-size: 12px; margin-top: 2px; }
.cols2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.cols3 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }

.stack > * + * { margin-top: 16px; }
.chart-box { position: relative; height: 260px; }
.quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 18px; }
.quick button { display: flex; align-items: center; gap: 12px; padding: 13px 14px; text-align: left; cursor: pointer; border: 1px solid var(--border); background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); }
.quick button:hover { border-color: var(--accent); }
.quick .ico { width: 34px; height: 34px; border-radius: 9px; background: var(--accent-bg); color: var(--accent); display: flex; align-items: center; justify-content: center; flex: none; }
.quick b { font-size: 14px; display: block; }
.quick span { color: var(--muted); font-size: 12px; }
.mini { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid #efece7; text-decoration: none; cursor: pointer; }
.mini:last-child { border-bottom: 0; }
.mini:hover { background: #faf8f5; }
.mini .grow { flex: 1; min-width: 0; }
.mini .t1 { font-weight: 600; }
.mini .t2 { color: var(--muted); font-size: 12px; margin-top: 1px; }
.bar { height: 6px; background: #efece7; border-radius: 4px; overflow: hidden; margin-top: 4px; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 4px; }

/* ---------- Cartes OT (technicien, planning) ---------- */
.wo-cards { display: grid; gap: 10px; }
.wo-card { background: #fff; border: 1px solid var(--border); border-left: 4px solid var(--border-strong); border-radius: var(--radius); padding: 12px 14px; cursor: pointer; box-shadow: var(--shadow); }
.wo-card:hover { border-color: var(--accent); }
.wo-card.pr-critical { border-left-color: var(--err); }
.wo-card.pr-high { border-left-color: var(--accent); }
.wo-card.pr-medium { border-left-color: var(--info); }
.wo-card .top { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.wo-card .ttl { font-weight: 600; margin: 6px 0 2px; }
.wo-card .meta { color: var(--muted); font-size: 12px; display: flex; gap: 10px; flex-wrap: wrap; margin-top: 4px; }
.wo-card .meta span { display: inline-flex; align-items: center; gap: 4px; }
.wo-card .meta .ic { width: 13px; height: 13px; }

/* ---------- Fiche (OT, machine) ---------- */
.detail { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 7px 12px; font-size: 13px; }
.kv > div:nth-child(odd) { color: var(--muted); }
.kv > div:nth-child(even) { font-weight: 500; overflow-wrap: anywhere; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.status-bar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 16px; box-shadow: var(--shadow); }
.steps { display: flex; gap: 4px; flex: 1; min-width: 240px; }
.steps div { flex: 1; text-align: center; font-size: 11px; font-weight: 600; color: var(--light); padding-top: 8px; border-top: 3px solid #e9e5de; white-space: nowrap; }
.steps div.done { color: var(--ok); border-top-color: var(--ok); }
.steps div.cur { color: var(--accent-dk); border-top-color: var(--accent); }
.checklist { display: grid; gap: 6px; }
.checklist label { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; background: #fff; }
.checklist label.done { background: var(--ok-bg); border-color: #bfe0cb; }
.checklist label.done span { text-decoration: line-through; color: var(--muted); }
.checklist input { width: 18px; height: 18px; accent-color: var(--ok); flex: none; margin-top: 1px; }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.photos .ph-item { position: relative; aspect-ratio: 4 / 3; border-radius: 8px; overflow: hidden; border: 1px solid var(--border); background: #f3f1ed; cursor: zoom-in; }
.photos img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photos .ph-item button { position: absolute; top: 4px; right: 4px; background: rgba(0, 0, 0, 0.55); color: #fff; border: 0; border-radius: 6px; padding: 3px; cursor: pointer; display: flex; }
.photos .add { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; border: 2px dashed var(--border-strong); border-radius: 8px; aspect-ratio: 4 / 3; color: var(--muted); cursor: pointer; font-size: 12px; }
.photos .add:hover { border-color: var(--accent); color: var(--ink); }
.sig-view { border: 1px solid var(--border); border-radius: 8px; padding: 8px; background: #fff; text-align: center; }
.sig-view img { max-width: 100%; max-height: 120px; }
.sig-pad { width: 100%; height: 220px; border: 2px dashed var(--border-strong); border-radius: 10px; background: #fff; touch-action: none; display: block; }
.timeline { position: relative; padding-left: 18px; }
.timeline::before { content: ''; position: absolute; left: 5px; top: 4px; bottom: 4px; width: 2px; background: #ece8e1; }
.timeline .ev { position: relative; padding-bottom: 12px; font-size: 13px; }
.timeline .ev::before { content: ''; position: absolute; left: -17px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: #fff; border: 2px solid var(--border-strong); }
.timeline .ev.status::before { border-color: var(--accent); }
.timeline .ev.comment::before { border-color: var(--info); }
.timeline .ev small { color: var(--light); display: block; }
.part-row { display: grid; grid-template-columns: 1fr 70px 32px; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid #efece7; }
.part-row:last-child { border-bottom: 0; }
.eq-chip { display: flex; align-items: center; gap: 10px; border: 1px solid var(--border-strong); border-radius: 8px; padding: 7px 8px 7px 12px; background: var(--soft); }
.eq-chip .ic { width: 20px; height: 20px; color: var(--accent); flex: none; }
.eq-chip > div { flex: 1; min-width: 0; }
.eq-chip small { display: block; color: var(--muted); font-size: 12px; }
.eq-head { display: flex; gap: 16px; align-items: flex-start; }
.eq-photo { width: 150px; height: 112px; border-radius: 10px; object-fit: cover; border: 1px solid var(--border); background: #f3f1ed; flex: none; }
.eq-photo.ph { display: flex; align-items: center; justify-content: center; color: var(--light); }
.eq-photo.ph .ic { width: 42px; height: 42px; }
.counter { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.due { font-size: 13px; font-weight: 600; }
.due.late { color: var(--err); }
.due.soon { color: var(--warn); }
.due.ok { color: var(--ok); }

/* ---------- Planning ---------- */
.plan-wrap { overflow-x: auto; }
.plan { display: grid; grid-template-columns: 150px repeat(7, minmax(112px, 1fr)); min-width: 940px; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; overflow: hidden; }
.plan > div { border-right: 1px solid #efece7; border-bottom: 1px solid #efece7; min-height: 92px; padding: 6px; }
.plan .hd { min-height: 0; background: var(--soft); font-size: 12px; font-weight: 600; color: var(--muted); padding: 9px 8px; text-transform: capitalize; }
.plan .hd.today { color: var(--accent-dk); background: var(--accent-bg); }
.plan .who { font-weight: 600; font-size: 13px; background: var(--soft); display: flex; flex-direction: column; justify-content: center; gap: 2px; }
.plan .who small { color: var(--muted); font-weight: 400; }
.plan .cell.today { background: #fffaf6; }
.plan .cell.over { background: var(--accent-bg); outline: 2px dashed var(--accent); outline-offset: -3px; }
.chip { display: block; font-size: 12px; border-radius: 6px; padding: 5px 7px; margin-bottom: 5px; cursor: grab; background: var(--info-bg); border-left: 3px solid var(--info); line-height: 1.3; }
.chip b { display: block; font-size: 11px; }
.chip.in_progress { background: var(--accent-bg); border-left-color: var(--accent); }
.chip.on_hold { background: var(--warn-bg); border-left-color: var(--warn); }
.chip.completed, .chip.billed { background: var(--ok-bg); border-left-color: var(--ok); opacity: 0.75; }
.chip.crit { box-shadow: inset 0 0 0 1px var(--err); }
.backlog { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; }
.backlog .chip { margin: 0; }
.day-list .day { margin-bottom: 14px; }
.day-list .day h4 { margin: 0 0 8px; font-size: 13px; text-transform: capitalize; color: var(--muted); }

/* ---------- Modale, toast, menus ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(27, 26, 24, 0.45); display: flex; align-items: flex-start; justify-content: center; padding: 5vh 16px; z-index: 100; overflow-y: auto; }
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 660px; box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25); }
.modal.lg { max-width: 920px; }
.modal.sm { max-width: 460px; }
.modal-h { padding: 15px 18px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.modal-h h3 { margin: 0; font-size: 16px; }
.modal-b { padding: 18px; }
.modal-f { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 9px; z-index: 200; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25); max-width: calc(100% - 32px); }
.toast.err { background: var(--err); }
.menu { position: relative; display: inline-block; }
.menu-list { position: absolute; right: 0; top: calc(100% + 4px); background: #fff; border: 1px solid var(--border); border-radius: 9px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12); min-width: 220px; z-index: 50; padding: 4px; }
.menu-list button { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; border: 0; background: none; padding: 8px 10px; border-radius: 6px; cursor: pointer; }
.menu-list button:hover { background: #f5f3ef; }
.menu-list button.danger { color: var(--err); }
.menu-list hr { border: 0; border-top: 1px solid var(--border); margin: 4px 0; }
.alert { padding: 10px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 12px; display: flex; gap: 8px; align-items: flex-start; }
.alert .ic { flex: none; margin-top: 1px; }
.alert.warn { background: var(--warn-bg); color: #6b4500; }
.alert.info { background: var(--info-bg); color: #1d4480; }
.alert.err { background: var(--err-bg); color: var(--err); }
.alert.ok { background: var(--ok-bg); color: var(--ok); }
.lightbox { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.85); z-index: 150; display: flex; align-items: center; justify-content: center; padding: 20px; cursor: zoom-out; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 6px; }

/* ---------- Autocomplétion ---------- */
.ac { position: relative; }
.ac-list { position: absolute; left: 0; right: 0; top: calc(100% + 2px); background: #fff; border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12); z-index: 40; max-height: 300px; overflow-y: auto; }
.ac-list div { padding: 8px 10px; cursor: pointer; border-bottom: 1px solid #f3f1ed; }
.ac-list div:last-child { border-bottom: 0; }
.ac-list div.on, .ac-list div:hover { background: #fbf4ef; }
.ac-list small { display: block; color: var(--muted); font-size: 12px; }
.drop { border: 2px dashed var(--border-strong); border-radius: 10px; padding: 26px; text-align: center; color: var(--muted); cursor: pointer; display: block; }
.drop:hover { border-color: var(--accent); color: var(--ink); }

/* ---------- Connexion ---------- */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; background: radial-gradient(1200px 600px at 20% 0%, #3a2a20 0%, transparent 60%), linear-gradient(160deg, #1b1a18 0%, #2c2925 100%); }
.login .card { width: 100%; max-width: 390px; padding: 28px; }
.login img { width: 150px; display: block; margin: 0 auto 10px; }
.login .app { text-align: center; font-size: 12px; font-weight: 700; letter-spacing: 0.18em; color: var(--accent); margin-bottom: 4px; }
.login h1 { font-size: 18px; text-align: center; margin: 0 0 20px; }

/* ---------- Documents A4 (rapport, fiche, étiquette) ---------- */
#print-root { display: none; }
.pdf-host { position: fixed; left: -10000px; top: 0; }
.a4 { width: 210mm; min-height: 297mm; background: #fff; color: #1b1a18; padding: 13mm 14mm 24mm; font: 10pt/1.4 Arial, Helvetica, sans-serif; position: relative; box-sizing: border-box; }
.a4 .hd { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 3px solid #e85d22; padding-bottom: 8px; margin-bottom: 10px; }
.a4 .hd img { height: 17mm; }
.a4 .hd .co { text-align: right; font-size: 8pt; color: #555; line-height: 1.35; }
.a4 .hd .co b { color: #1b1a18; font-size: 9pt; }
.a4 h1 { font-size: 15pt; margin: 2mm 0 1mm; letter-spacing: 0.02em; }
.a4 .ref { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 4mm; }
.a4 .ref .no { font-size: 12pt; font-weight: 700; color: #b8471a; }
.a4 .boxes { display: grid; grid-template-columns: 1fr 1fr; gap: 3mm; margin-bottom: 3mm; }
.a4 .box { border: 1px solid #d6d1c8; border-radius: 2mm; padding: 2.5mm 3mm; }
.a4 .box h3, .a4 .sec h3 { margin: 0 0 1.5mm; font-size: 8pt; text-transform: uppercase; letter-spacing: 0.06em; color: #b8471a; }
.a4 .kvp { display: grid; grid-template-columns: 30mm 1fr; gap: 0.6mm 2mm; font-size: 9pt; }
.a4 .kvp > div:nth-child(odd) { color: #6f6a63; }
.a4 .sec { margin-bottom: 3mm; }
.a4 .sec .txt { border: 1px solid #e4e0d8; border-radius: 2mm; padding: 2mm 3mm; min-height: 9mm; white-space: pre-line; font-size: 9.5pt; }
.a4 table { width: 100%; border-collapse: collapse; font-size: 9pt; }
.a4 th { background: #f3f1ed; text-align: left; padding: 1.5mm 2mm; border: 1px solid #d6d1c8; font-size: 8pt; }
.a4 td { padding: 1.5mm 2mm; border: 1px solid #e4e0d8; }
.a4 td.r, .a4 th.r { text-align: right; }
.a4 .chk { columns: 2; font-size: 9pt; }
.a4 .chk div { break-inside: avoid; }
.a4 .sigs { display: grid; grid-template-columns: 1fr 1fr; gap: 4mm; margin-top: 3mm; }
.a4 .sigs .box { height: 34mm; position: relative; }
.a4 .sigs img { max-height: 20mm; max-width: 100%; display: block; margin: 1mm auto 0; }
.a4 .sigs .who { position: absolute; bottom: 2mm; left: 3mm; right: 3mm; font-size: 8.5pt; color: #555; }
.a4 .pics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 2mm; }
.a4 .pics img { width: 100%; height: 30mm; object-fit: cover; border-radius: 1.5mm; }
.a4 .note { font-size: 8pt; color: #6f6a63; margin-top: 2mm; }
.a4 .ft { position: absolute; left: 14mm; right: 14mm; bottom: 8mm; border-top: 1px solid #e4e0d8; padding-top: 2mm; font-size: 7.5pt; color: #777; text-align: center; line-height: 1.4; }
.a4 .label { width: 150mm; margin: 25mm auto 0; border: 2px solid #1b1a18; border-radius: 5mm; padding: 8mm; display: grid; grid-template-columns: 58mm 1fr; gap: 8mm; align-items: center; }
.a4 .label .qr svg, .a4 .label .qr img { width: 58mm; height: 58mm; display: block; }
.a4 .label .code { font-size: 22pt; font-weight: 700; letter-spacing: 0.02em; }
.a4 .label .nm { font-size: 12pt; font-weight: 700; margin: 1mm 0 3mm; }
.a4 .label .inf { font-size: 9.5pt; color: #444; line-height: 1.5; }
.a4 .label .sav { margin-top: 4mm; background: #e85d22; color: #fff; border-radius: 2mm; padding: 2mm 3mm; font-size: 9pt; font-weight: 700; }
.a4 .label img.logo { height: 11mm; margin-bottom: 3mm; }

@media print {
  @page { size: A4; margin: 0; }
  body.printing > *:not(#print-root) { display: none !important; }
  body.printing #print-root { display: block; }
  body.printing { background: #fff; }
  #print-root .a4 { page-break-after: always; break-after: page; margin: 0; min-height: 296mm; }
  #print-root .a4:last-child { page-break-after: auto; break-after: auto; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1150px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .quick { grid-template-columns: repeat(2, 1fr); }
  .detail { grid-template-columns: 1fr; }
  .cols3 { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .side { position: fixed; left: 0; top: 0; bottom: 0; width: 264px; z-index: 90; transform: translateX(-100%); transition: transform 0.2s; }
  .layout.nav-open .side { transform: none; box-shadow: 10px 0 40px rgba(0, 0, 0, 0.3); }
  .layout.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.35); z-index: 80; }
  .topbar { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--side); color: #fff; position: sticky; top: 0; z-index: 70; }
  .topbar button { background: none; border: 0; color: #fff; padding: 6px; cursor: pointer; display: flex; }
  .topbar img { height: 26px; background: #fff; border-radius: 5px; padding: 2px 4px; }
  .topbar .ic { width: 22px; height: 22px; }
  .topbar .grow { flex: 1; }
  .page { padding: 16px 14px 70px; }
  .cols2 { grid-template-columns: 1fr; }
  .grid4 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 600px) {
  .kpis { grid-template-columns: 1fr 1fr; gap: 8px; }
  .kpi { padding: 12px; gap: 8px; }
  .kpi .ico { width: 32px; height: 32px; }
  .kpi .v { font-size: 20px; }
  .quick { grid-template-columns: 1fr 1fr; }
  .quick button { padding: 10px; gap: 8px; }
  .quick span { display: none; }
  .grid2, .grid3, .grid4 { grid-template-columns: 1fr; }
  .span2, .span3 { grid-column: auto; }
  .hide-sm { display: none !important; }
  table.t td, table.t th { padding: 9px 8px; }
  .ph h1 { font-size: 19px; }
  .kv { grid-template-columns: 110px 1fr; }
  .eq-head { flex-direction: column; }
  .eq-photo { width: 100%; height: 180px; }
  .steps { display: none; }
  .filters .in, .filters .grow { flex: 1 1 100%; max-width: none; }
  .modal-bg { padding: 0; }
  .modal { border-radius: 0; min-height: 100vh; }
}
.show-sm { display: none !important; }
@media (max-width: 600px) { .wo-cards.show-sm { display: grid !important; } .show-sm:not(.wo-cards) { display: block !important; } }

/* ---------- Lignes à facturer ---------- */
.bl-row { display: grid; grid-template-columns: 24px 1fr; gap: 8px; padding: 12px 0; border-bottom: 1px solid #efece7; }
.bl-row:last-child { border-bottom: 0; }
.bl-chk { width: 18px; height: 18px; accent-color: var(--accent); margin-top: 9px; }
.bl-nums { display: grid; grid-template-columns: 100px 160px 1fr; gap: 8px; margin-top: 8px; }
.bl-nums .r { text-align: right; }
@media (max-width: 600px) { .bl-nums { grid-template-columns: 80px 1fr; } .bl-nums .r { grid-column: 1 / -1; padding-bottom: 0 !important; } }
