:root {
  --bg: #f3f0ea;
  --surface: #ffffff;
  --surface-2: #faf8f4;
  --ink: #1d1b18;
  --ink-2: #57524a;
  --ink-3: #8a847a;
  --line: #e4dfd5;
  --line-2: #d3ccbf;
  --accent: #2f5d50;
  --accent-soft: #e2ebe7;
  --warn: #a8610b;
  --warn-soft: #fbf1e3;
  --info: #3a6ea5;
  --late: #b03a2e;
  --late-soft: #fbe9e7;
  --info-soft: #e6eef7;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font: 14px/1.45 Inter, system-ui, sans-serif; color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
[hidden] { display: none !important; }
.muted { color: var(--ink-3); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.mono { font-family: var(--mono); font-size: 12.5px; white-space: nowrap; }
.nowrap { white-space: nowrap; }

/* top bar */
.topbar { height: 56px; display: flex; align-items: center; gap: 28px; padding: 0 20px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.brand { white-space: nowrap; flex: none; display: flex; align-items: center; gap: 9px; font-weight: 650; font-size: 15px; letter-spacing: -0.01em; color: var(--ink); text-decoration: none; }
nav { display: flex; gap: 2px; }
nav a { display: flex; align-items: center; gap: 7px; padding: 7px 12px; border-radius: 8px; color: var(--ink-2); text-decoration: none; font-weight: 500; }
nav a:hover { color: var(--ink); background: var(--surface-2); }
nav a.on { background: var(--accent-soft); color: var(--accent); }
.count:empty { display: none; }
.count { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--accent); color: #fff; font-size: 11.5px; font-weight: 600; display: inline-grid; place-items: center; }
.topbar-note { margin-left: auto; color: var(--ink-3); font-size: 12.5px; }

main { height: calc(100% - 56px); }
.view { height: 100%; }

/* buttons */
.primary { background: var(--accent); color: #fff; border: 0; border-radius: 9px; padding: 10px 18px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.primary:hover { background: #274f44; }
.primary:disabled { background: #b9c4bf; cursor: not-allowed; }
.blocked { color: var(--late); font-size: 13px; font-weight: 600; }
.ghost { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 7px 12px; font-size: 13px; cursor: pointer; white-space: nowrap; }
.ghost:hover { border-color: var(--line-2); }
.link { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; text-decoration: underline; font-size: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* designer */
.design { display: grid; grid-template-columns: minmax(0, 1fr) 372px; grid-template-rows: minmax(0, 1fr) auto; grid-template-areas: "stage panel" "summary panel"; }
.stage { grid-area: stage; position: relative; min-height: 0; overflow: hidden; }
.viewport { position: absolute; inset: 0; }
.viewport canvas { display: block; cursor: grab; }
.viewport canvas:active { cursor: grabbing; }
.drawing-pane { position: absolute; inset: 0; background: #fff; padding: 64px 28px 28px; display: flex; align-items: center; justify-content: center; }
.drawing-pane svg { width: 100%; height: 100%; }
.stage-top { position: absolute; top: 14px; left: 14px; right: 14px; display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; pointer-events: none; }
.stage-top > * { pointer-events: auto; }
.presets { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: rgba(255, 255, 255, .86); backdrop-filter: blur(6px); padding: 6px 11px; border-radius: 999px; font-size: 12.5px; color: var(--ink-2); cursor: pointer; }
.chip:hover { color: var(--ink); border-color: var(--line-2); }
.seg { display: flex; background: rgba(255, 255, 255, .92); border: 1px solid var(--line); border-radius: 9px; padding: 3px; flex: none; }
.seg button { border: 0; background: none; font-size: 12.5px; padding: 5px 11px; border-radius: 6px; color: var(--ink-2); cursor: pointer; white-space: nowrap; }
.seg button.on { background: var(--ink); color: #fff; }
.reset { position: absolute; right: 14px; bottom: 14px; }
/* 3D preview: open the fronts, show or hide parts (picture only) */
.view-opts { position: absolute; right: 14px; bottom: 56px; display: flex; gap: 6px; align-items: center; }
.view-opts .view-opts-btn { background: rgba(255, 255, 255, .92); }
.view-opts .badge { font-size: 11px; color: var(--accent); margin-left: 4px; }
.view-opts-pop { position: absolute; right: 0; bottom: calc(100% + 6px); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px 4px; box-shadow: 0 8px 24px rgba(0, 0, 0, .12); min-width: 230px; }
.view-opts-pop .toggle { margin-bottom: 8px; }
.view-opts-pop .hint { font-size: 11.5px; color: var(--ink-2); margin: 2px 0 6px; }
.dims-chip { position: absolute; left: 14px; bottom: 14px; font: 500 12px var(--mono); color: var(--ink-2); background: rgba(255, 255, 255, .82); padding: 5px 9px; border-radius: 6px; pointer-events: none; }

.product-picker { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 14px 0 12px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); z-index: 3; }
.product-picker button { display: flex; flex-direction: column; align-items: center; gap: 4px; border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 9px 6px 8px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.product-picker button:hover:not(:disabled) { border-color: var(--line-2); color: var(--ink); }
.product-picker button.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.product-picker button:disabled { opacity: .45; cursor: not-allowed; }
.board-tools { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.kind { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; }
.kind.big { font-size: 12px; vertical-align: middle; padding: 2px 7px; }
.ghost.small { padding: 5px 9px; font-size: 12px; }
.inline-num { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--ink-2); margin-bottom: 8px; }
.field.select { display: block; }
.field.select select, .select select { width: 100%; border: 1px solid var(--line-2); border-radius: 8px; padding: 7px 9px; background: var(--surface); font-size: 13px; }
.toggle { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); margin-bottom: 12px; cursor: pointer; }
.toggle input { accent-color: var(--accent); width: 16px; height: 16px; }
.panel { grid-area: panel; background: var(--surface); border-left: 1px solid var(--line); overflow-y: auto; padding: 4px 20px 28px; }
.section { padding: 16px 0 4px; border-bottom: 1px solid var(--line); }
.section h3, .checks h3, .job-checks h3 { margin: 0 0 12px; font-size: 11.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-3); font-weight: 600; }
.field { margin-bottom: 14px; }
.field .label { display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: var(--ink-2); margin-bottom: 7px; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 6px 10px; font-size: 12.5px; cursor: pointer; display: flex; align-items: center; gap: 6px; }
.pill:hover { border-color: var(--line-2); }
.pill.on { border-color: var(--ink); background: var(--ink); color: #fff; }
.swatches { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.swatch { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 6px 8px; font-size: 12.5px; text-align: left; cursor: pointer; }
.swatch:hover { border-color: var(--line-2); }
.swatch.on { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.swatch .sw { width: 22px; height: 22px; border-radius: 5px; flex: none; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12); }
.cchip-group { margin-top: 6px; }
.cchip-title { font-size: 11.5px; color: var(--muted, #6b665e); margin-bottom: 4px; }
.cchips { display: flex; flex-wrap: wrap; gap: 6px; }
.cchip { width: 32px; height: 32px; padding: 3px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); cursor: pointer; }
.cchip span { display: block; width: 100%; height: 100%; border-radius: 5px; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12); }
.cchip:hover { border-color: var(--line-2); }
.cchip.on { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.slope-row { display: grid; grid-template-columns: minmax(0, 1fr) 92px 92px; gap: 6px; align-items: center; font-size: 12.5px; margin-top: 6px; }
.slope-row .num input { width: 100%; }
input[type=range] { width: 100%; accent-color: var(--accent); margin: 0; }
.num { display: flex; align-items: center; gap: 5px; }
.num input { width: 70px; text-align: right; border: 1px solid var(--line); border-radius: 6px; padding: 3px 6px; font: 500 12.5px var(--mono); background: var(--surface-2); }
.num em { font-style: normal; color: var(--ink-3); font-size: 12px; }
.hint { font-size: 12px; color: var(--accent); margin-top: 5px; font-weight: 500; }
.banner { margin: 14px 0 0; padding: 10px 12px; background: var(--accent-soft); border-radius: 8px; font-size: 13px; line-height: 1.5; }
.checks { padding-top: 16px; }
.check-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.check-list li { display: flex; gap: 9px; align-items: baseline; font-size: 13px; line-height: 1.45; color: var(--ink-2); }
.check-list .lvl { flex: none; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: 1px 6px; border-radius: 4px; background: var(--info-soft); color: var(--info); }
.check-list .warn .lvl { background: var(--warn-soft); color: var(--warn); }
.check-list .error .lvl { background: var(--late-soft); color: var(--late); }
.check-list .warn, .check-list .error { color: var(--ink); }
.ok { margin: 0; font-size: 13px; color: var(--accent); }

.summary { grid-area: summary; display: flex; align-items: center; gap: clamp(12px, 1.8vw, 30px); padding: 12px 20px; background: var(--surface); border-top: 1px solid var(--line); min-width: 0; }
/* stats give way (ellipsis, full text in their title); the price link, the blocking notice and
   the send button keep their size */
.summary { container-type: inline-size; }
.summary .stat { flex: 0 1 auto; min-width: 4.5em; }
.summary .stat.price { flex: none; }
/* a narrow bar drops the secondary figures first (they stay in « Détail du prix » and the panel) */
@container (max-width: 1080px) { .summary .stat.opt:not(.lead) { display: none; } }
@container (max-width: 800px) { .summary .stat.lead { display: none; } }
@container (max-width: 1000px) { .summary .stat.lead:has(~ .blocked) { display: none; } }
.stat .k, .stat .v, .stat .s { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat .k { font-size: 11.5px; color: var(--ink-3); }
.stat .v { font-weight: 600; font-variant-numeric: tabular-nums; }
.summary .primary, .summary .blocked, .summary .est-link { flex: none; white-space: nowrap; }
.spacer { flex: 1 1 0; min-width: 0; }

/* production board */
.production { display: flex; flex-direction: column; padding: 20px 20px 0; }
.board-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.board-head h1 { font-size: 20px; margin: 0; letter-spacing: -0.01em; }
.board-head p { margin: 3px 0 0; color: var(--ink-3); }
.board { display: grid; grid-template-columns: repeat(var(--cols, 5), minmax(220px, 1fr)); gap: 12px; flex: 1; min-height: 0; overflow-x: auto; padding-bottom: 20px; }
.col { background: #ebe7df; border-radius: 12px; display: flex; flex-direction: column; min-height: 0; }
.col.over { box-shadow: inset 0 0 0 2px var(--accent); }
.col-head { display: flex; justify-content: space-between; padding: 12px 14px 9px; font-weight: 600; font-size: 13px; }
.col-head .n { color: var(--ink-3); font-weight: 500; }
.col-body { padding: 0 8px 8px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.empty { color: var(--ink-3); font-size: 12.5px; padding: 18px 8px; text-align: center; border: 1px dashed var(--line-2); border-radius: 9px; }
.card { display: block; background: var(--surface); border-radius: 9px; border: 1px solid var(--line); overflow: hidden; flex: none; }
.card-link { display: block; text-decoration: none; color: inherit; }
.card .next { display: block; width: 100%; border: 0; border-top: 1px solid var(--line); background: var(--surface-2); padding: 7px 12px; font-size: 12px; color: var(--accent); font-weight: 600; text-align: left; cursor: pointer; }
.card .next:hover { background: var(--accent-soft); }
.card:hover { border-color: var(--line-2); box-shadow: 0 2px 10px rgba(40, 30, 10, .06); }
.card.dragging { opacity: .45; }
.card img { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; display: block; background: #ebe7e0; }
.card-body { padding: 10px 12px 11px; }
.card-top { display: flex; align-items: center; gap: 6px; font-size: 12.5px; }
.cust { font-weight: 600; margin-top: 3px; }
.card-spec { color: var(--ink-3); font-size: 12px; margin-top: 2px; }
.card-stage { font-size: 11.5px; font-weight: 600; color: var(--accent); margin-top: 4px; }
.keep { break-inside: avoid; }
.card-foot { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; color: var(--ink-2); font-size: 12px; margin-top: 8px; }
.tag { font-size: 11px; font-weight: 600; background: var(--accent-soft); color: var(--accent); padding: 1px 6px; border-radius: 4px; }
.tag.big { font-size: 13px; vertical-align: middle; padding: 2px 8px; }
.due { margin-left: auto; font-size: 11.5px; color: var(--ink-3); }
.due.soon { color: var(--warn); font-weight: 600; }
.due.late { color: var(--late); font-weight: 600; }
#board-sub b.soon { color: var(--warn); }
#board-sub b.late { color: var(--late); }

/* job sheet */
.jobview { overflow-y: auto; }
.job { max-width: 1160px; margin: 0 auto; padding: 22px 24px 64px; }
.back { font-size: 13px; text-decoration: none; color: var(--ink-2); }
.back:hover { color: var(--ink); }
.eyebrow { font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--accent); font-weight: 600; }
.job-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; flex-wrap: wrap; margin-bottom: 20px; }
.job-head h1 { margin: 4px 0 2px; font-size: 26px; letter-spacing: -0.02em; }
.job-head .sub { color: var(--ink-2); }
.job-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
/* Grouped actions: the rarely used files and documents sit behind two named menus,
   so "Imprimer la fiche" is the only accented button in the header. */
.menu { position: relative; }
.menu > summary { list-style: none; display: inline-flex; align-items: center; gap: 6px; }
.menu > summary::-webkit-details-marker { display: none; }
.menu > summary::after { content: ''; width: 6px; height: 6px; border: solid var(--ink-3); border-width: 0 1.5px 1.5px 0; transform: translateY(-2px) rotate(45deg); }
.menu[open] > summary { border-color: var(--line-2); background: var(--surface-2); }
.menu-pop { position: absolute; left: 0; top: calc(100% + 6px); z-index: 30; min-width: 220px; display: flex; flex-direction: column; padding: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 28px rgba(29, 27, 24, .12); }
.menu-pop .ghost { border: 0; text-align: left; padding: 8px 10px; border-radius: 6px; }
.menu-pop .ghost:hover { background: var(--surface-2); }
/* section shortcuts: one scrolling row, never wrapped */
.jump { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; mask-image: linear-gradient(to right, #000 92%, transparent); margin: -6px 0 18px; padding-bottom: 2px; }
.jump button { flex: none; border: 0; background: none; padding: 5px 10px; border-radius: 999px; font-size: 12.5px; color: var(--ink-2); cursor: pointer; white-space: nowrap; }
.jump button:hover { background: var(--surface); color: var(--ink); }
.sheet-section { scroll-margin-top: 16px; }
.stage-sel { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); margin-right: 4px; }
.stage-sel select { border: 1px solid var(--line-2); border-radius: 8px; padding: 7px 10px; background: var(--surface); font-weight: 600; }
.job-grid { display: grid; grid-template-columns: 340px minmax(0, 1fr) 300px; gap: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px; align-items: start; }
.job-photo { width: 100%; border-radius: 8px; display: block; background: #ebe7e0; }
.spec { border-collapse: collapse; width: 100%; font-size: 13px; }
.spec th { text-align: left; font-weight: 500; color: var(--ink-3); padding: 5px 12px 5px 0; white-space: nowrap; vertical-align: top; width: 1%; }
.spec td { padding: 5px 0; }
.sheet-section { margin-top: 28px; }
.section-head { display: flex; align-items: baseline; gap: 14px; margin-bottom: 10px; flex-wrap: wrap; }
.section-head h2 { margin: 0; font-size: 16px; }
.section-head .muted { font-size: 12.5px; }
.sheet { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 20px 20px 0; overflow: hidden; }
.sheet svg { width: 100%; height: auto; display: block; max-height: 640px; }
.sheet-scroll { overflow-x: auto; }
.titleblock { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); border-top: 1px solid var(--line); margin: 12px -20px 0; font-size: 12.5px; font-weight: 600; }
.titleblock div { padding: 7px 14px; border-left: 1px solid var(--line); border-bottom: 1px solid var(--line); min-width: 0; overflow-wrap: anywhere; }
.titleblock div:nth-child(6n + 1) { border-left: 0; }
.titleblock .wide { grid-column: span 2; }
.titleblock span { display: block; font-size: 10.5px; font-weight: 500; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); }
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow-x: auto; }
.data { width: 100%; border-collapse: collapse; font-size: 13px; }
.data th { text-align: left; font-weight: 600; font-size: 12px; color: var(--ink-3); padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; }
.data td { padding: 9px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.data tr:last-child td { border-bottom: 0; }
.data .r { text-align: right; white-space: nowrap; }
.data .note { color: var(--ink-2); }
.log { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 8px; max-width: 760px; }
.log .sys { display: flex; justify-content: space-between; gap: 12px; font-size: 12.5px; color: var(--ink-3); padding: 0 2px; }
.log .msg { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; }
.log .who { display: flex; gap: 10px; align-items: baseline; font-size: 13px; }
.log time { font-size: 12px; color: var(--ink-3); }
.log p { margin: 3px 0 0; }
.comment-form { display: flex; gap: 8px; max-width: 760px; }
.comment-form select, .comment-form input { border: 1px solid var(--line-2); border-radius: 8px; padding: 9px 11px; background: var(--surface); }
.comment-form input { flex: 1; min-width: 0; }
.totals { display: flex; flex-wrap: wrap; gap: 6px 20px; margin: 10px 2px 0; font-size: 13px; }
.notes-h { margin-top: 18px !important; }
.consignes { margin: 0; font-size: 13px; background: var(--warn-soft); border-radius: 8px; padding: 9px 12px; }
.print-header { display: none; }
/* cabinet rows and the cabinet editor (kitchen) */
.mod-row { padding: 7px 0; border-top: 1px solid var(--line); }
.mod-row.on { background: var(--surface-2); margin: 0 -10px; padding: 7px 10px 10px; border-radius: 8px; border-top-color: transparent; box-shadow: inset 3px 0 0 var(--accent); }
.mod-btn { position: relative; display: flex; align-items: center; justify-content: center; gap: 4px; height: 30px; border: 1px solid var(--line-2); background: var(--surface); border-radius: 7px; cursor: pointer; font-size: 12.5px; color: var(--ink); }
.mod-btn:hover { border-color: var(--accent); }
.mod-btn.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.mod-btn i { position: absolute; top: -3px; right: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--warn); border: 1.5px solid var(--surface); }
.mod-price { font-size: 12px; color: var(--ink-2); margin-right: 4px; }
/* the row's head: a small elevation of the module, its name and what it holds, its price */
.mod-head { display: grid; grid-template-columns: 46px minmax(0, 1fr) auto; gap: 10px; align-items: center; width: 100%; text-align: left; }
.mod-head.mod-btn { height: auto; justify-content: stretch; padding: 5px 8px 5px 6px; }
.mod-head.mod-btn.on { background: var(--surface); color: var(--ink); border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.mod-name { display: flex; flex-direction: column; gap: 1px; min-width: 0; line-height: 1.25; }
.mod-name b { font-size: 13px; font-weight: 600; }
.mod-sub { font-size: 12px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mod-ref { font-size: 11px; color: var(--ink-3, var(--ink-2)); opacity: .8; }
.mod-pic { display: block; color: var(--ink); }
.mod-pic .mp-box { fill: var(--surface-2); stroke: currentColor; stroke-width: .6; opacity: .7; }
.mod-pic .mp-front { fill: var(--surface); stroke: currentColor; stroke-width: .8; }
.mod-pic .mp-glass { fill: #cfe3ec; stroke: currentColor; stroke-width: .8; }
.mod-pic .mp-dark { fill: #2c2d30; stroke: currentColor; stroke-width: .6; }
.mod-pic .mp-blind { fill: var(--line-2); stroke: currentColor; stroke-width: .6; }
.mod-pic .mp-plinth { fill: currentColor; opacity: .35; }
.mod-pic .mp-top { fill: currentColor; opacity: .55; }
.mod-pic .mp-void { fill: none; stroke: currentColor; stroke-width: .9; stroke-dasharray: 2.5 2; opacity: .7; }
.mod-pic .mp-line { fill: none; stroke: currentColor; stroke-width: .6; opacity: .75; }
.cab-ed { margin-top: 10px; display: flex; flex-direction: column; gap: 9px; }
.cab-title { font-size: 13px; }
.cab-f { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--ink-2); }
.cab-f select { width: 100%; border: 1px solid var(--line-2); border-radius: 7px; padding: 5px 7px; background: var(--surface); font-size: 12.5px; color: var(--ink); }
.cab-fixed { padding: 5px 0; color: var(--ink); }
.cab-dims { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.cab-price { width: 100%; border-collapse: collapse; font-size: 12px; }
.cab-price td { padding: 3px 0; border-top: 1px solid var(--line); vertical-align: top; }
.cab-price td.mono { text-align: right; white-space: nowrap; padding-left: 8px; }
.cab-price .tot td { font-weight: 650; color: var(--ink); border-top: 1px solid var(--line-2); }
.field-hint { margin: -6px 0 0; font-size: 12.5px; color: var(--accent); min-height: 1em; }
.dlg-error { margin: 0; font-size: 13px; color: var(--late); font-weight: 600; }
.dlg-error:empty { display: none; }
.dlg-warn:empty { display: none; }
.dlg-warn p { margin: 0 0 6px; }

/* dialog */
dialog { border: 0; border-radius: 14px; padding: 0; width: min(560px, calc(100vw - 32px)); box-shadow: 0 20px 60px rgba(30, 20, 5, .25); }
dialog::backdrop { background: rgba(29, 27, 24, .35); }
dialog form { padding: 22px 24px 20px; display: grid; gap: 14px; }
dialog h2 { margin: 0; font-size: 18px; }
.dlg-summary { margin: -8px 0 0; font-size: 13px; }
dialog label { display: grid; gap: 5px; font-size: 13px; color: var(--ink-2); font-weight: 500; }
dialog input, dialog textarea, dialog select { border: 1px solid var(--line-2); border-radius: 8px; padding: 9px 11px; font-weight: 400; color: var(--ink); background: var(--surface); resize: vertical; }
dialog .row { display: grid; grid-template-columns: 1fr 1fr 80px; gap: 10px; }
.dlg-warn { margin: 0; font-size: 13px; color: var(--ink-2); background: var(--warn-soft); border-radius: 8px; padding: 9px 12px 3px; }
.dlg-warn:empty { display: none; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; }

.toast { position: fixed; left: 50%; top: 68px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 11px 16px; border-radius: 10px; font-size: 13.5px; z-index: 50; box-shadow: 0 10px 30px rgba(0, 0, 0, .2); max-width: calc(100vw - 32px); }
.toast a { color: #9fd3c1; margin-left: 8px; font-weight: 600; }
#thumb-host { position: fixed; left: -10000px; top: 0; width: 640px; height: 400px; }

/* estimate */
.est-link { font-size: 12.5px; white-space: nowrap; }
.est-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 10px; }
.est-kpis div { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.est-kpis span { display: block; font-size: 11.5px; color: var(--ink-3); }
.est-kpis b { font-size: 17px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.est-kpis small { display: block; font-size: 11.5px; color: var(--ink-3); margin-top: 2px; }
.est-lead { margin: 0 0 12px; font-size: 13px; color: var(--ink-2); }
.est-table tr.grp td { background: var(--surface-2); font-weight: 600; font-size: 12px; color: var(--ink-2); text-transform: uppercase; letter-spacing: .04em; padding-top: 7px; padding-bottom: 7px; }
.est-table tr.tot td { font-weight: 700; border-top: 2px solid var(--line-2); }
.est-table tr.big td { font-size: 14.5px; }
.est-table .sub { display: block; font-size: 11.5px; color: var(--ink-3); margin-top: 2px; }
.est-note { font-size: 12px; margin: 8px 2px 0; }
#est-dialog { width: min(860px, calc(100vw - 32px)); max-height: calc(100vh - 48px); }
.est-dlg { padding: 18px 22px 20px; }
.est-dlg-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.est-dlg-head h2 { margin: 0; font-size: 18px; }
.dlg-est { font-size: 13px; background: var(--accent-soft); border-radius: 8px; padding: 10px 12px; }
.dlg-est:empty { display: none; }
.dlg-est p { margin: 6px 0 0; color: var(--ink-2); }
.dlg-est-row { display: flex; flex-wrap: wrap; gap: 4px 16px; font-variant-numeric: tabular-nums; }
.dlg-late { color: var(--late) !important; font-weight: 600; }

/* tarifs */
.tarifs .tf-preview { list-style: none; margin: 0 0 18px; padding: 10px 14px; background: var(--accent-soft); border-radius: 10px; display: grid; gap: 4px; font-size: 13px; }
.tf-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.tf-card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.tf-card h2 { margin: 0 0 10px; font-size: 15px; }
.tf { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 13px; color: var(--ink-2); margin-bottom: 9px; }
.tf select, .tf input[type=text] { border: 1px solid var(--line-2); border-radius: 7px; padding: 5px 8px; background: var(--surface); font-size: 13px; max-width: 60%; }
.tf input.short { width: 80px; }
.tf .num input, .tf-table input { width: 110px; text-align: right; border: 1px solid var(--line); border-radius: 6px; padding: 4px 7px; font: 500 12.5px var(--mono); background: var(--surface-2); }
.tf .days { display: flex; flex-wrap: wrap; gap: 4px 10px; }
.tf .days label { display: flex; align-items: center; gap: 4px; font-size: 12.5px; }
.tf-h { margin: 26px 0 2px; font-size: 16px; }
.tf-card.wide { grid-column: 1 / -1; }
.tf-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 32px; }
.tf-cols input[type=text] { width: 60%; }
.tf-card textarea { width: 100%; border: 1px solid var(--line-2); border-radius: 8px; padding: 8px 10px; font: 12.5px/1.5 var(--mono); background: var(--surface-2); resize: vertical; margin-bottom: 6px; }
.tf.tf-block { flex-direction: column; align-items: stretch; margin-top: 6px; }
.tf-table td:first-child { min-width: 0; }
.tf-product { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; margin-top: 12px; padding: 4px 16px 12px; }
.tf-product summary { display: flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 600; padding: 10px 0; }
.tf-product summary .muted { font-weight: 400; font-size: 12.5px; margin-left: auto; }
.tf-product h3 { margin: 12px 0 6px; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); }
.tf-table td { padding: 5px 10px; }
.tf-table td.unit { color: var(--ink-3); white-space: nowrap; width: 1%; }
.tf-table td:last-child { width: 1%; white-space: nowrap; }
.tf-table tr.custom td { background: var(--warn-soft); }
.tf-ap-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px 0; }
.tf-ap-actions .hint { margin: 0; }
.tf-ap-report { margin: 4px 0 10px; padding: 8px 10px; border-radius: 7px; background: var(--surface-2); font-size: 12.5px; color: var(--ink-2); }
.tf-ap td { padding: 4px 6px; }
.tf-ap input, .tf-ap select { width: 100%; min-width: 70px; border: 1px solid var(--line); border-radius: 6px; padding: 4px 7px; font-size: 12.5px; background: var(--surface-2); }
.tf-ap input[type=number] { text-align: right; font-family: var(--mono); min-width: 90px; }
.tf-ap td:last-child { width: 1%; white-space: nowrap; }
.tf-su-cats { display: flex; flex-wrap: wrap; gap: 2px 10px; min-width: 260px; font-size: 12px; }
.tf-su-cats label { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.tf-ap .tf-su-cats input { width: auto; min-width: 0; }
.tf-ap [aria-invalid="true"] { border-color: var(--late); background: var(--late-soft); }
.tf-ap-missing { margin: 6px 0 0; font-size: 12.5px; color: var(--late); }
.est-disc { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 18px; align-items: center; margin: 0 0 12px; padding: 8px 10px; border-radius: 8px; background: var(--surface-2); }
.est-disc .tf { margin: 0; }
.est-disc .tf input[type=text] { max-width: none; flex: 1; }
.dv-totals .dv-disc { color: #555; }
.file-btn { display: inline-flex; align-items: center; cursor: pointer; }

/* narrow screens */
@media screen and (max-width: 1100px) {
  .job-grid { grid-template-columns: 1fr 1fr; }
  .job-checks { grid-column: 1 / -1; }
}
@media screen and (max-width: 860px) {
  .topbar { gap: 10px; padding: 0 12px; }
  .brand { font-size: 14px; }
  nav a { padding: 7px 9px; }
  .topbar-note { display: none; }
  main { height: auto; }
  .view { height: auto; }
  .design { display: flex; flex-direction: column; }
  .stage { height: 58vh; min-height: 340px; }
  .stage-top { flex-direction: column-reverse; align-items: stretch; gap: 8px; left: 10px; right: 10px; top: 10px; }
  .presets { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
  .presets::-webkit-scrollbar { display: none; }
  .chip { flex: none; }
  .seg { align-self: flex-end; }
  .dims-chip { display: none; }
  .drawing-pane { padding: 96px 0 0; overflow: auto; align-items: flex-start; justify-content: flex-start; }
  .drawing-pane svg { width: 860px; height: auto; flex: none; }
  .panel { border-left: 0; padding: 0 16px 24px; }
  .summary { position: sticky; bottom: 0; flex-wrap: wrap; gap: 8px 18px; padding: 10px 16px; z-index: 5; }
  .summary .stat.opt, .summary .spacer { display: none; }
  .summary .primary, .summary .blocked { width: 100%; white-space: normal; }
  .summary .stat { flex: 1 1 40%; }
  .production { padding: 16px; }
  .board-head { flex-direction: column; align-items: flex-start; }
  .board { display: flex; flex-direction: column; overflow: visible; }
  .card-link { display: flex; }
  .card img { width: 112px; aspect-ratio: auto; object-fit: cover; flex: none; }
  .card-body { min-width: 0; }
  .job { padding: 18px 16px 48px; }
  .job-grid { grid-template-columns: 1fr; }
  .sheet { padding: 12px 0 0; }
  .sheet-scroll svg { width: 760px; max-height: none; }
  .titleblock { grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 12px 0 0; }
  .titleblock div, .titleblock div:nth-child(6n + 1) { border-left: 1px solid var(--line); }
  .titleblock div:nth-child(odd) { border-left: 0; }
  .titleblock .wide { grid-column: span 2; border-left: 0; }
  .table-wrap { background: none; border: 0; }
  table.cards, table.cards tbody, table.cards tr, table.cards td { display: block; width: 100%; }
  table.cards thead { display: none; }
  table.cards tr { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; margin-bottom: 8px; }
  table.cards td { border: 0 !important; padding: 3px 0; text-align: left !important; display: flex; gap: 10px; }
  table.cards td::before { content: attr(data-label); flex: 0 0 104px; color: var(--ink-3); font-size: 12px; font-family: Inter, system-ui, sans-serif; font-weight: 500; }
  dialog .row { grid-template-columns: 1fr 1fr; }
  .toast { top: 64px; }
  .est-kpis { grid-template-columns: 1fr 1fr; }
  .tf-grid, .tf-cols { grid-template-columns: 1fr; }
  .tf { flex-wrap: wrap; }
  .tf > span:first-child { flex: 1 1 100%; }
  .tf select, .tf input[type=text] { max-width: 100%; width: 100%; }
  .tf-product { padding: 4px 10px 10px; }
  .tf-table, .tf-table tbody, .tf-table tr { display: block; width: 100%; }
  .tf-table tr { display: grid; grid-template-columns: 1fr auto auto; gap: 4px 8px; align-items: center; padding: 8px 2px; border-bottom: 1px solid var(--line); }
  .tf-table td { display: block; padding: 0 !important; border: 0 !important; }
  .tf-table td:first-child { grid-column: 1 / -1; font-size: 13px; }
  .tf-table td.r input { width: 120px; }
  .tf-table td:last-child:empty { display: none; }
  .tf-ap, .tf-ap tbody, .tf-ap tr { display: block; width: 100%; }
  .tf-ap thead { display: none; }
  .tf-ap tr { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 8px; padding: 8px 2px; border-bottom: 1px solid var(--line); }
  .tf-ap td { display: block; padding: 0 !important; border: 0 !important; }
  .tf-ap td:first-child { grid-column: 1 / -1; }
  .est-disc { grid-template-columns: 1fr; }
  .tarifs .job-actions { width: 100%; }
  .est-link { width: 100%; text-align: left; }
}

@media print {
  @page { size: A4 landscape; margin: 12mm 10mm 12mm; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  html, body { background: #fff; font-size: 11px; height: auto; }
  .topbar, .job-actions, .jump, .back, .comment-form, .toast, #view-design, #view-production { display: none !important; }
  main, .view, .jobview { height: auto !important; overflow: visible !important; }
  .job { max-width: none; padding: 0; }
  .job-head { margin-bottom: 8px; }
  .job-head h1 { font-size: 20px; margin: 0; }
  .job-grid { grid-template-columns: 120mm minmax(0, 1.1fr) minmax(0, 1fr); gap: 16px; padding: 10px; border-color: #ccc; break-inside: avoid; }
  .job-photo { height: auto; }
  .spec td { overflow-wrap: anywhere; }
  .section-head { break-after: avoid; margin-bottom: 6px; }
  .sheet-section { margin-top: 12px; }
  .sheet-section.drawing { break-before: page; margin-top: 0; }
  .sheet { border-color: #ccc; padding: 6px 8px 0; break-inside: avoid; }
  .sheet svg { max-height: 140mm; }
  .titleblock { margin: 6px -8px 0; font-size: 9.5px; break-inside: avoid; }
  .sheet-section.break { break-before: page; margin-top: 0; }
  .table-wrap { border-color: #ccc; }
  .data tr { break-inside: avoid; }
  .data td, .data th { padding: 4px 8px; }
  .activity .log { max-width: none; }
  .log li { break-inside: avoid; }
  .log .sys { display: none; }
  body:not(.print-quote) .sheet-section.estimate { display: none !important; }
  body.print-quote .job > :not(.job-head):not(.sheet-section.estimate) { display: none !important; }
  body.print-quote .sheet-section.estimate { margin-top: 0; }
  .est-kpis { grid-template-columns: repeat(4, 1fr); }
  .sheet-section.extra { break-inside: auto; }
  .sheet-section.extra h3, .sheet-section.extra h4, .section-head { break-after: avoid; }
  .keep { break-inside: avoid; }

  /* labels and client quote: printed on their own, on A4 portrait */
  .labels-preview { display: none !important; }
  body.print-labels .job > :not(.labels-print), body.print-devis .job > :not(.devis-print) { display: none !important; }
  .labels-print { page: labels; }
  .labels-page { display: grid; grid-template-columns: repeat(3, 63.5mm); grid-auto-rows: 38.1mm; column-gap: 2.5mm; break-after: page; }
  .labels-page:last-child { break-after: auto; }
  .labels-print .plabel { border: 0.2mm dashed #ccc; border-radius: 0; }
  .devis-print { page: devis; font-size: 10.5px; }
}
@page labels { size: A4 portrait; margin: 15mm 7mm 0; @top-left { content: none; } @bottom-right { content: none; } }
@page devis { size: A4 portrait; margin: 14mm 14mm 16mm; @top-left { content: none; } }
@media screen { .labels-print, .devis-print { display: none; } }

/* ---------- part labels ---------- */
.labels-grid { display: grid; grid-template-columns: repeat(auto-fill, 63.5mm); gap: 8px; }
.plabel { width: 63.5mm; height: 38.1mm; padding: 2.4mm 2.6mm; display: grid; grid-template-columns: minmax(0, 1fr) 17mm; gap: 1.6mm; background: #fff; border: 1px solid var(--line); border-radius: 6px; font-size: 7.2pt; line-height: 1.25; overflow: hidden; color: #111; break-inside: avoid; }
.lb-main { min-width: 0; display: flex; flex-direction: column; gap: 0.5mm; }
.lb-top { display: flex; align-items: baseline; gap: 1.6mm; min-width: 0; }
.lb-mark { font-size: 15pt; line-height: 1; letter-spacing: -0.02em; }
.lb-part { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-dims { font-family: var(--mono); font-size: 9pt; font-weight: 600; }
.lb-row { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #333; }
.lb-foot { margin-top: auto; font-size: 6.2pt; color: #666; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-side { display: flex; flex-direction: column; align-items: center; justify-content: space-between; gap: 1mm; }
.lb-qr svg { width: 17mm; height: 17mm; display: block; }
.lb-band { width: 17mm; height: auto; display: block; }

/* ---------- client quote ---------- */
.devis-print { color: #1b1b1b; max-width: 182mm; margin: 0 auto; }
.dv-head { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 2px solid var(--accent); padding-bottom: 10px; }
.dv-brand { font-size: 20px; font-weight: 700; color: var(--accent); }
.dv-ref { text-align: right; line-height: 1.5; }
.dv-title { font-size: 22px; font-weight: 700; letter-spacing: 0.02em; text-transform: uppercase; }
.dv-muted { color: #6b665e; font-size: 0.92em; }
.dv-k { display: block; font-size: 0.8em; text-transform: uppercase; letter-spacing: 0.06em; color: #6b665e; margin-bottom: 2px; }
.dv-parties { display: grid; grid-template-columns: 1fr 1.6fr; gap: 16px; margin: 14px 0; }
.dv-body { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.dv-img { width: 100%; border-radius: 6px; background: #f3f0ea; }
.dv-spec { border-collapse: collapse; width: 100%; }
.dv-spec th { text-align: left; font-weight: 500; color: #6b665e; padding: 3px 10px 3px 0; vertical-align: top; white-space: nowrap; }
.dv-spec td { padding: 3px 0; }
.dv-lines { width: 100%; border-collapse: collapse; margin-top: 16px; }
.dv-lines th { text-align: left; font-size: 0.85em; text-transform: uppercase; letter-spacing: 0.04em; color: #6b665e; border-bottom: 1px solid #bbb; padding: 6px 8px; }
.dv-lines td { border-bottom: 1px solid #ddd; padding: 8px; vertical-align: top; }
.dv-lines .r { text-align: right; white-space: nowrap; }
.dv-detail td { padding: 5px 8px; }
.dv-detail .dv-grp td { padding: 9px 8px 3px; font-weight: 650; font-size: 0.9em; text-transform: uppercase; letter-spacing: 0.04em; color: var(--accent); border-bottom: 1px solid #bbb; }
.dv-refc { font-family: var(--mono); font-size: 0.92em; white-space: nowrap; }
.dv-detail tr { break-inside: avoid; }
.dv-sub td { font-weight: 600; border-top: 1px solid #bbb; }
.dv-room { margin-top: 6px; }
.dv-totals { margin: 10px 0 0 auto; width: 70mm; break-inside: avoid; }
.dv-totals div { display: flex; justify-content: space-between; padding: 3px 8px; }
.dv-ttc { background: var(--accent); color: #fff; border-radius: 4px; font-size: 1.15em; margin-top: 4px; padding: 6px 8px !important; }
.dv-cond { margin-top: 16px; line-height: 1.5; }
.dv-cond p { margin: 0 0 6px; }
.dv-sign { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 18px; }
.dv-sign > div { border: 1px solid #bbb; border-radius: 4px; height: 30mm; padding: 6px 8px; }

.flash { background: var(--accent-soft) !important; outline: 2px solid var(--accent); }

@media screen and (max-width: 480px) {
  .brand { font-size: 0; gap: 0; }
  nav { gap: 0; min-width: 0; }
  nav a { padding: 6px 8px; font-size: 13.5px; }
}
.stat .s { display: block; font-size: 11px; color: var(--ink-3); white-space: nowrap; }
