:root {
  --bg-light: #f6f5f1;       --bg-dark: #121614;
  --surface-light: #ffffff;  --surface-dark: #1b211e;
  --surface2-light: #efede6; --surface2-dark: #232b27;
  --text-light: #1d2320;     --text-dark: #e7ebe8;
  --muted-light: #5f6a64;    --muted-dark: #9aa6a0;
  --border-light: #dcd9cf;   --border-dark: #313a35;
  --brand-light: #0f766e;    --brand-dark: #2dd4bf;
  --brand-text-light: #fff;  --brand-text-dark: #062a26;
  --ok-light: #15803d;       --ok-dark: #4ade80;
  --warn-light: #b45309;     --warn-dark: #fbbf24;
  --bad-light: #b91c1c;      --bad-dark: #f87171;

  --bg: var(--bg-light); --surface: var(--surface-light); --surface2: var(--surface2-light);
  --text: var(--text-light); --muted: var(--muted-light); --border: var(--border-light);
  --brand: var(--brand-light); --brand-text: var(--brand-text-light);
  --ok: var(--ok-light); --warn: var(--warn-light); --bad: var(--bad-light);

  @media (prefers-color-scheme: dark) {
    --bg: var(--bg-dark); --surface: var(--surface-dark); --surface2: var(--surface2-dark);
    --text: var(--text-dark); --muted: var(--muted-dark); --border: var(--border-dark);
    --brand: var(--brand-dark); --brand-text: var(--brand-text-dark);
    --ok: var(--ok-dark); --warn: var(--warn-dark); --bad: var(--bad-dark);
  }
  @supports (color: light-dark(white, black)) {
    --bg: light-dark(var(--bg-light), var(--bg-dark));
    --surface: light-dark(var(--surface-light), var(--surface-dark));
    --surface2: light-dark(var(--surface2-light), var(--surface2-dark));
    --text: light-dark(var(--text-light), var(--text-dark));
    --muted: light-dark(var(--muted-light), var(--muted-dark));
    --border: light-dark(var(--border-light), var(--border-dark));
    --brand: light-dark(var(--brand-light), var(--brand-dark));
    --brand-text: light-dark(var(--brand-text-light), var(--brand-text-dark));
    --ok: light-dark(var(--ok-light), var(--ok-dark));
    --warn: light-dark(var(--warn-light), var(--warn-dark));
    --bad: light-dark(var(--bad-light), var(--bad-dark));
  }

  color-scheme: light dark;
  accent-color: var(--brand);
  --radius: 10px;
  --mono: ui-monospace, "Cascadia Code", Consolas, monospace;
}

/* Theme chosen in the app (Réglages / ◐) overrides the system preference. */
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }
@supports not (color: light-dark(white, black)) {
  :root[data-theme="light"] {
    --bg: var(--bg-light); --surface: var(--surface-light); --surface2: var(--surface2-light);
    --text: var(--text-light); --muted: var(--muted-light); --border: var(--border-light);
    --brand: var(--brand-light); --brand-text: var(--brand-text-light);
    --ok: var(--ok-light); --warn: var(--warn-light); --bad: var(--bad-light);
  }
  :root[data-theme="dark"] {
    --bg: var(--bg-dark); --surface: var(--surface-dark); --surface2: var(--surface2-dark);
    --text: var(--text-dark); --muted: var(--muted-dark); --border: var(--border-dark);
    --brand: var(--brand-dark); --brand-text: var(--brand-text-dark);
    --ok: var(--ok-dark); --warn: var(--warn-dark); --bad: var(--bad-dark);
  }
}

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
a.comp-link { color: inherit; text-decoration: none; }
a.comp-link:hover b { color: var(--brand); text-decoration: underline; }

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 15px/1.5 system-ui, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
}
a { color: var(--brand); }
h1 { font-size: 1.5rem; margin: 0 0 .25rem; }
h2 { font-size: 1.15rem; margin: 1.5rem 0 .6rem; }
h3 { font-size: 1rem; margin: 0 0 .4rem; }
p { margin: .4rem 0; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); }
.small { font-size: .85rem; }
[hidden] { display: none !important; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 1rem;
  padding: .6rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: .5rem; font-weight: 700; font-size: 1.1rem; color: var(--text); text-decoration: none; }
.mainnav { display: flex; gap: .25rem; overflow-x: auto; flex: 1; scrollbar-width: none; }
.mainnav a {
  padding: .4rem .7rem; border-radius: 8px; text-decoration: none; color: var(--muted); white-space: nowrap;
}
.mainnav a:hover { background: var(--surface2); color: var(--text); }
.mainnav a[aria-current="page"] { background: var(--surface2); color: var(--brand); font-weight: 600; }

@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; gap: .4rem; padding: .5rem .75rem; }
  .mainnav { order: 3; flex-basis: 100%; }
  .top-tools { margin-left: auto; }
}

main { max-width: 1180px; margin: 0 auto; padding: 1.25rem 1rem 4rem; outline: none; }

/* ---------- Controls ---------- */
button, .btn {
  font: inherit; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
  padding: .45rem .9rem; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  text-decoration: none; white-space: nowrap;
}
button:hover, .btn:hover { border-color: var(--brand); }
button.primary, .btn.primary { background: var(--brand); color: var(--brand-text); border-color: var(--brand); font-weight: 600; }
button.danger { color: var(--bad); }
button.ghost { background: transparent; border-color: transparent; }
button.small, .btn.small { padding: .2rem .55rem; font-size: .85rem; }
button:disabled { opacity: .5; cursor: progress; }

input, select, textarea {
  font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: .45rem .6rem; width: 100%;
}
textarea { resize: vertical; min-height: 5rem; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--brand); outline-offset: 1px;
}
label { display: grid; gap: .2rem; font-size: .88rem; color: var(--muted); }
label > span { font-weight: 500; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: .75rem; }
.form-grid .wide { grid-column: 1 / -1; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.actions.end { justify-content: flex-end; }
.toolbar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin: 1rem 0; }
.toolbar input[type="search"] { flex: 1 1 240px; width: auto; }
.toolbar select { width: auto; }
.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end; gap: .75rem; }

/* ---------- Cards / stats ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; }
.grid { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.stats { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin: 1rem 0; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .8rem 1rem; text-decoration: none; color: inherit; }
.stat b { display: block; font-size: 1.6rem; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: .88rem; }
a.card { text-decoration: none; color: inherit; display: block; }
a.card:hover, a.stat:hover { border-color: var(--brand); }
.quick { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.quick a.card b { display: block; color: var(--brand); margin-bottom: .2rem; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .5rem .65rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); background: var(--surface2); font-weight: 600; }
tr:last-child td { border-bottom: 0; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: var(--surface2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.qty { display: inline-flex; align-items: center; gap: .3rem; }
.qty button { width: 1.8rem; height: 1.8rem; padding: 0; }
.qty b { min-width: 2.5ch; text-align: center; font-variant-numeric: tabular-nums; }

@media (max-width: 720px) {
  table.responsive thead { display: none; }
  table.responsive tr { display: grid; grid-template-columns: 1fr auto; gap: .1rem .75rem; padding: .6rem .75rem; border-bottom: 1px solid var(--border); }
  table.responsive td { border: 0; padding: 0; }
  table.responsive td[data-hide-mobile] { display: none; }
  table.responsive td.num { text-align: left; }
}

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: .05rem .5rem; border-radius: 999px; font-size: .78rem; font-weight: 600; border: 1px solid currentColor; white-space: nowrap; }
.badge.ok { color: var(--ok); }
.badge.partial, .badge.warn { color: var(--warn); }
.badge.missing { color: var(--bad); }
.badge.neutral { color: var(--muted); }
.cat { font-size: .78rem; color: var(--muted); }
.low { color: var(--bad); font-weight: 600; }

.progress { display: flex; height: 8px; border-radius: 99px; overflow: hidden; background: var(--surface2); margin: .5rem 0; }
.progress i { display: block; }
.progress .ok { background: var(--ok); }
.progress .partial { background: var(--warn); }
.progress .missing { background: var(--bad); }

/* ---------- Dialog ---------- */
dialog {
  width: min(680px, calc(100vw - 1.5rem)); max-height: calc(100dvh - 2rem);
  border: 1px solid var(--border); border-radius: 14px; padding: 0;
  background: var(--surface); color: var(--text);
}
dialog::backdrop { background: rgb(0 0 0 / .45); backdrop-filter: blur(2px); }
.modal-inner { padding: 1.25rem; }
.modal-inner h2 { margin-top: 0; }
.modal-inner .actions.end { margin-top: 1.25rem; }

/* ---------- Toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: 1.25rem; translate: -50% 0;
  background: var(--text); color: var(--bg); padding: .6rem 1rem; border-radius: 8px;
  opacity: 0; pointer-events: none; transition: opacity .2s; max-width: calc(100vw - 2rem); z-index: 100;
}
#toast.show { opacity: 1; }
#toast.error { background: var(--bad); color: #fff; }

/* ---------- Misc ---------- */
.empty { text-align: center; padding: 2.5rem 1rem; color: var(--muted); }
.notice { border-left: 4px solid var(--brand); background: var(--surface); padding: .75rem 1rem; border-radius: 0 var(--radius) var(--radius) 0; margin: 1rem 0; }
.notice.warn { border-color: var(--warn); }
.pre { white-space: pre-wrap; }
.spinner { display: inline-block; width: 1em; height: 1em; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { rotate: 360deg; } }
.dropzone { border: 2px dashed var(--border); border-radius: var(--radius); padding: 2rem 1rem; text-align: center; background: var(--surface); }
.dropzone.drag { border-color: var(--brand); }
.photo-preview { max-width: 100%; max-height: 320px; border-radius: var(--radius); display: block; margin: .75rem auto; }
.draft { display: grid; gap: .6rem; }

/* ---------- Circuits ---------- */
.tabs { display: flex; gap: .25rem; overflow-x: auto; border-bottom: 1px solid var(--border); margin: 1rem 0; scrollbar-width: thin; }
.tabs a { padding: .55rem .9rem; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a:hover { color: var(--text); }
.tabs a[aria-current="page"] { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }
.steps-intro { list-style: none; counter-reset: s; padding: 0; margin: 1rem 0; display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.steps-intro li { counter-increment: s; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .75rem 1rem; display: grid; gap: .2rem; }
.steps-intro li::before { content: counter(s); display: grid; place-items: center; width: 1.6rem; height: 1.6rem; border-radius: 50%; background: var(--brand); color: var(--brand-text); font-weight: 700; font-size: .85rem; }
.steps-intro span { color: var(--muted); font-size: .88rem; }
.net-grid { display: grid; gap: .6rem; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.net { padding: .7rem .85rem; }
.chips { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .4rem; }
.pin-chip { font-size: .8rem; padding: .1rem .45rem; border-radius: 6px; background: var(--surface2); font-family: var(--mono); }
.pin-chip i { font-style: normal; color: var(--muted); font-family: system-ui, sans-serif; }
table.pins { margin-top: .4rem; font-size: .82rem; }
table.pins td { padding: .15rem .4rem; }
.checklist { padding-left: 1.2rem; display: grid; gap: .5rem; }
.checklist label { display: flex; gap: .45rem; align-items: baseline; color: var(--text); font-size: .95rem; }
.checklist input { width: auto; }
.checklist p { margin: .15rem 0 0 1.5rem; color: var(--muted); }
.plain { list-style: none; padding: 0; margin: .3rem 0; display: grid; gap: .3rem; }
.review { margin-bottom: .75rem; }
.issue { border-top: 1px solid var(--border); padding-top: .5rem; margin-top: .5rem; }
.issue p { margin: .25rem 0 0; }
.log { max-height: 240px; overflow: auto; background: var(--surface2); padding: .6rem; border-radius: 8px; font-size: .75rem; white-space: pre-wrap; }
.board-views { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); margin-top: 1rem; }
.board-views figure { margin: 0; }
.board-views figcaption { font-size: .85rem; color: var(--muted); margin-bottom: .4rem; }
.board-views img { width: 100%; height: auto; border-radius: 8px; background: #000; }
.board-views img.light { background: #f5f1e8; }
.order-grid { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
textarea.mono { font-family: var(--mono); font-size: .8rem; }

/* ---------- Location tree ---------- */
.crumbs { font-size: .9rem; color: var(--muted); }
.tree { list-style: none; margin: 0; padding-left: 1.25rem; border-left: 1px dashed var(--border); }
.tree.root { padding-left: 0; border: 0; margin-top: 1rem; display: grid; gap: .75rem; }
.tree.root > li { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .75rem 1rem; }
.tree li { margin: .35rem 0; }
.tree-node { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; text-decoration: none; color: var(--text); }
.tree-node:hover b { color: var(--brand); }
.tree-node .kind { width: 1.4rem; text-align: center; }
.tree-map { display: block; max-width: 340px; margin: .5rem 0 .25rem 1.9rem; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: .6rem .8rem .4rem; margin: 0; }
legend { font-size: .85rem; color: var(--muted); padding: 0 .3rem; }
.swatches { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .3rem; }
.swatch { display: block; position: relative; cursor: pointer; }
.swatch input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; pointer-events: none; }
.swatch span { display: grid; place-items: center; width: 1.8rem; height: 1.8rem; border-radius: 6px; background: var(--c); border: 1px solid var(--border); color: var(--muted); font-size: .8rem; }
.swatch input:checked + span { outline: 2px solid var(--brand); outline-offset: 2px; }
.swatch input:focus-visible + span { outline: 2px solid var(--brand); }
.suggest { display: flex; flex-wrap: wrap; gap: .3rem; align-items: center; margin-top: .25rem; }
.chip { border-radius: 999px; }
.sel-list { display: grid; gap: .15rem; max-height: 280px; overflow: auto; }
.sel { display: flex; gap: .4rem; align-items: center; color: var(--text); font-size: .9rem; }
details > summary { cursor: pointer; }
.where { margin: 1rem 0; }
.where .gf-grid { max-width: 420px; margin-top: .6rem; }
/* On a bin's page, the plan is a way to jump from bin to bin */
.where.nav .gf-grid.compact { pointer-events: auto; }
.where.nav .gf-cell { pointer-events: none; }
.where.nav .gf-bin:not(.hl) { cursor: pointer; }
.where.nav .gf-bin:not(.hl):hover { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 18%, var(--surface)); }

/* ---------- Gridfinity plan ---------- */
.gf-grid {
  --gap: 4px;
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  grid-template-rows: repeat(var(--rows), minmax(0, 1fr));
  aspect-ratio: var(--cols) / var(--rows);
  gap: var(--gap);
  padding: var(--gap);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: min(100%, calc(var(--cols) * 150px));
}
.gf-cell, .gf-bin { min-width: 0; min-height: 0; padding: .3rem; border-radius: 7px; font-size: .78rem; }
.gf-cell { border: 1px dashed var(--border); background: transparent; color: var(--muted); }
.gf-cell span { opacity: .6; }
.gf-cell:hover { border-color: var(--brand); color: var(--brand); }
.gf-bin {
  display: flex; flex-direction: column; align-items: flex-start; justify-content: flex-start; gap: .1rem;
  text-align: left; white-space: normal; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: inset 0 4px 0 var(--bin, var(--border));
}
.gf-bin b { font-size: .85rem; }
.gf-bin small { color: var(--muted); line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 3; line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.gf-bin i { font-style: normal; font-size: .72rem; color: var(--muted); margin-top: auto; }
.gf-bin.hl { background: var(--brand); color: var(--brand-text); border-color: var(--brand); }
.gf-bin.hl small, .gf-bin.hl i { color: inherit; }
.gf-bin.moving { outline: 3px solid var(--warn); outline-offset: 1px; }
/* Drag & drop of bins (mouse, or long press on a phone) */
.gf-bin { position: relative; z-index: 1; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; cursor: grab; }
.gf-bin.dragging { opacity: .35; }
.gf-bin.picked { outline: 3px solid var(--brand); outline-offset: 1px; background: color-mix(in srgb, var(--brand) 22%, var(--surface)); }
.gf-drop {
  z-index: 2; pointer-events: none; border-radius: 7px; padding: .3rem; font-size: .75rem; font-weight: 600;
  border: 2px solid var(--brand); background: color-mix(in srgb, var(--brand) 25%, transparent); color: var(--text);
}
.gf-drop.bad { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 25%, transparent); }
/* Boxes simply set down in the drawer (no Gridfinity bin) */
.gf-bin.box { border-style: dashed; background: color-mix(in srgb, var(--warn) 10%, var(--surface)); }
/* Stacked levels: the bins underneath show through as outlines */
.gf-ghost { pointer-events: none; border: 1px dashed color-mix(in srgb, var(--muted) 60%, transparent); border-radius: 7px; padding: .2rem .3rem; font-size: .68rem; color: var(--muted); opacity: .7; }
.tabs button[role="tab"] { border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none; color: var(--muted); padding: .55rem .9rem; white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--brand); border-bottom-color: var(--brand); }
/* Straightened photo of the drawer behind the plan */
.gf-grid.has-photo { background: var(--surface2) var(--photo) center / 100% 100% no-repeat; }
.gf-grid.has-photo .gf-cell { background: color-mix(in srgb, var(--surface2) 35%, transparent); }
.gf-grid.has-photo .gf-bin { background: color-mix(in srgb, var(--surface) 72%, transparent); }
/* Placing the 4 corners of the baseplate on a drawer photo */
.corner-stage { position: relative; margin: .5rem 0; touch-action: none; user-select: none; }
.corner-stage img { display: block; width: 100%; height: auto; border-radius: 6px; }
.corner-stage svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.corner-stage line { stroke: var(--brand); opacity: .9; }
.corner {
  position: absolute; width: 2.2rem; height: 2.2rem; margin: -1.1rem 0 0 -1.1rem; padding: 0; border-radius: 50%;
  display: grid; place-items: center; font-size: .7rem; font-weight: 700; cursor: grab; touch-action: none;
  background: color-mix(in srgb, var(--brand) 35%, transparent); border: 2px solid var(--brand); color: #fff; text-shadow: 0 0 3px #000;
}
/* Drawer plan inside the location form (live preview of the bin being edited) */
.loc-preview .gf-grid { max-width: min(100%, calc(var(--cols) * 70px)); --gap: 3px; margin: .3rem 0; }
.loc-preview .gf-cell, .loc-preview .gf-bin { font-size: .65rem; padding: .15rem; }
.loc-preview .gf-bin small, .loc-preview .gf-bin i { display: none; }
.loc-preview .gf-bin:not(.hl) { pointer-events: none; opacity: .75; }
.loc-preview.bad .gf-bin.hl { background: var(--bad); border-color: var(--bad); }
.error-text { color: var(--bad); }
.gf-grid.compact { --gap: 2px; pointer-events: none; }
.gf-grid.compact .gf-cell, .gf-grid.compact .gf-bin { padding: 2px; font-size: .62rem; border-radius: 4px; }
.gf-grid.compact .gf-bin b { font-size: .62rem; }
@media (max-width: 720px) {
  .gf-cell, .gf-bin { font-size: .65rem; padding: .15rem; }
  .gf-bin small { display: none; }
}

/* ---------- Gridfinity labels (true size in mm) ---------- */
.gf-labels { display: flex; flex-wrap: wrap; gap: 2mm; }
.gf-label {
  display: flex; align-items: center; gap: 1.2mm; padding: .6mm 1.2mm;
  background: #fff; color: #000; border: .2mm dashed #999; border-radius: 1mm;
  overflow: hidden; break-inside: avoid; font-family: system-ui, "Segoe UI", sans-serif;
}
.gf-label img { height: 100%; aspect-ratio: 1; flex: none; image-rendering: pixelated; }
.gf-label .txt { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; line-height: 1.05; }
.gf-label b { font-size: 3.2mm; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gf-label span { font-size: 2.1mm; color: #444; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gf-label .bands { width: 10mm; height: auto; flex: none; }

/* ---------- Drawer front labels (true size in mm, text scaled to the label height) ---------- */
.drawer-labels { display: flex; flex-wrap: wrap; gap: 3mm; }
.drawer-label {
  display: flex; align-items: center; gap: calc(var(--h) * .1); padding: calc(var(--h) * .08);
  background: #fff; color: #000; border: .2mm dashed #999; border-radius: 1.5mm;
  overflow: hidden; break-inside: avoid; font-family: system-ui, "Segoe UI", sans-serif;
}
.drawer-label img { height: 100%; aspect-ratio: 1; flex: none; image-rendering: pixelated; }
.drawer-label .nfc-mark.big { font-size: calc(var(--h) * .5); }
.drawer-label .txt { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; line-height: 1.1; }
.drawer-label b { font-size: calc(var(--h) * .34); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.drawer-label span { font-size: calc(var(--h) * .15); color: #222; display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.drawer-label small { font-size: calc(var(--h) * .11); color: #555; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sheet-title { margin: 1rem 0 .4rem; font-size: .95rem; color: var(--muted); }

/* ---------- QR labels (print) ---------- */
.labels { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: .5rem; }
.label { border: 1px dashed var(--border); border-radius: 8px; padding: .5rem; display: grid; grid-template-columns: 72px 1fr; gap: .5rem; align-items: center; background: #fff; color: #000; break-inside: avoid; }
.label img { width: 72px; height: 72px; }
.label b { display: block; font-size: .95rem; line-height: 1.2; }
.label span { font-size: .72rem; color: #444; }

@media print {
  .topbar, .no-print, #toast { display: none !important; }
  body, main { background: #fff; padding: 0; max-width: none; }
  .labels { grid-template-columns: repeat(3, 1fr); gap: 4mm; }
  .label { border-color: #999; }
  .gf-labels, .drawer-labels { margin-bottom: 4mm; }
  .roll .gf-labels, .roll .drawer-labels { display: block; margin: 0; }
  .roll .gf-label, .roll .drawer-label { border: 0; border-radius: 0; break-after: page; }
}

/* Fields just filled by the AI: highlight until the user reviews them */
.ai-filled { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 8%, var(--surface)); }
.cad-results { list-style: none; padding: 0; margin: .75rem 0 0; display: grid; gap: .5rem; }
.cad-results .card { padding: .7rem .85rem; }
.cad-results p { margin: .25rem 0; }

/* ---------- Component images & documents ---------- */
.name-cell { display: flex; align-items: center; gap: .6rem; }
.thumb { width: 40px; height: 40px; flex: none; border-radius: 8px; object-fit: cover; background: var(--surface2); border: 1px solid var(--border); }
.thumb.placeholder, .hero.placeholder { display: grid; place-items: center; color: var(--muted); font-size: 1rem; }
.comp-top { display: grid; gap: .75rem; grid-template-columns: minmax(180px, 260px) 1fr; margin: 1rem 0; align-items: stretch; }
.comp-top > .card { display: flex; flex-direction: column; justify-content: center; }
@media (max-width: 560px) { .comp-top { grid-template-columns: 1fr; } }
.image-card { padding: .6rem; }
.hero-img { padding: 0; border: 0; background: none; display: block; width: 100%; cursor: zoom-in; }
.hero-img:disabled { cursor: default; opacity: 1; }
.hero { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: contain; border-radius: 8px; background: var(--surface2); }
.hero.placeholder { font-size: 3rem; }
.lightbox-img { display: block; max-width: 100%; max-height: 70dvh; margin: 0 auto; border-radius: 8px; background: #fff; }
.doc-grid { display: grid; gap: .6rem; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.doc { margin: 0; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); display: flex; flex-direction: column; }
.doc-preview { display: grid; place-items: center; height: 120px; width: 100%; padding: 0; border: 0; border-radius: 0; background: var(--surface2); text-decoration: none; color: var(--muted); cursor: zoom-in; }
.doc-preview img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.doc-preview.pdf { cursor: pointer; }
.doc-preview.pdf span { font-size: 2.4rem; }
.doc-preview.pdf small { font-weight: 700; letter-spacing: .08em; }
.doc figcaption { padding: .45rem .6rem .55rem; display: grid; gap: .15rem; min-width: 0; }
.doc figcaption b { font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc figcaption .actions { gap: .6rem; }

/* ---------- Phone connection ---------- */
.top-tools { display: flex; gap: .15rem; align-items: center; }
.top-tools .btn, .top-tools button { white-space: nowrap; }
@media (max-width: 900px) { .top-tools .tool-label { display: none; } }
.phone-qr { display: grid; grid-template-columns: 220px 1fr; gap: 1rem; align-items: center; }
.phone-qr img, .phone-qr .qr-box { width: 220px; height: 220px; background: #fff; border-radius: 10px; padding: 6px; }
.phone-qr .qr-box svg { width: 100%; height: 100%; display: block; }
.phone-steps { padding-left: 1.2rem; margin: 0 0 .5rem; display: grid; gap: .25rem; }
@media (max-width: 560px) { .phone-qr { grid-template-columns: 1fr; justify-items: center; } }
.segmented { display: inline-flex; flex-wrap: wrap; gap: .35rem; }

/* ---------- NFC ---------- */
.copy-row { display: flex; gap: .4rem; align-items: flex-start; }
.copy-row input, .copy-row textarea { flex: 1; min-height: 0; font-size: .85rem; }
.nfc-badge { font-size: .7em; }
.nfc-mark { flex: none; font-size: 3mm; line-height: 1; }
.nfc-mark.big { font-size: 1.6rem; width: 72px; text-align: center; }

/* ---------- Tailscale ---------- */
.ts-steps { padding-left: 1.3rem; display: grid; gap: .3rem; }
.ts-steps li.done { color: var(--muted); text-decoration: line-through; }
.ts-steps li.done::marker { content: '✔ '; color: var(--ok); }
.ts-steps li.current { font-weight: 500; }

/* ---------- Mode mixte (consultation à distance) ---------- */
.mode-banner { background: var(--warn); color: #1d1400; text-align: center; padding: .45rem 1rem; font-size: .9rem; font-weight: 500; }
body.readonly :is([data-adj], [data-edit], #addComp, #edit, #compAi, #nfcComp, #addLoc, #addChild, #addHere, #editLoc, #nfcLoc, #moveMode, #fill,
  #imgUrl, #imgRm, #docUrl, #docDs, #docSearch, #cadSearch, #cadRm, .image-card label.btn, #docs label.btn, #cad label.btn,
  #newProj, #addItem, #importBom, #makePcb, #consume, #dup, #pDelete, #pEdit, #newCirc, #cDelete, #cStatus,
  a[href="#/importer"], a[href="#/photo"], a[href="#/ajout-ia"], a[href="#/stock?new=1"], .quick) { display: none !important; }
body.readonly .gf-cell { pointer-events: none; }

/* ---------- Connexion ---------- */
body.locked .mainnav, body.locked #phoneBtn, body.locked #modeBanner { display: none !important; }
.login-card { max-width: 360px; margin: 10vh auto 0; }
.login-card .brand { font-size: 1.4rem; }

/* ---------- Plateforme en ligne : connexion, bannières, compte ---------- */
.auth-wrap { min-height: calc(100dvh - 8rem); display: grid; place-items: start center; }
.auth-wrap .login-card { margin-top: 6vh; width: min(400px, 100%); }
.auth-sep { display: flex; align-items: center; gap: .6rem; color: var(--muted); font-size: .85rem; margin: 1rem 0; }
.auth-sep::before, .auth-sep::after { content: ''; flex: 1; border-top: 1px solid var(--border); }
.lang-switch { display: inline-flex; gap: .25rem; }
label.check { display: flex; flex-direction: row; gap: .45rem; align-items: baseline; color: var(--text); font-size: .9rem; }
label.check input { width: auto; }
.saas-banner { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; justify-content: center; padding: .45rem 1rem; font-size: .9rem; border-bottom: 1px solid var(--border); }
.saas-banner.info { background: color-mix(in srgb, var(--brand) 12%, var(--surface)); }
.saas-banner.warn { background: color-mix(in srgb, var(--warn) 18%, var(--surface)); }
.saas-banner.bad { background: var(--bad); color: #fff; font-weight: 500; }
#accountBtn { position: relative; }
#accountBtn .dot { position: absolute; top: 4px; right: 4px; width: 8px; height: 8px; border-radius: 50%; background: var(--warn); }
.twofa-setup { display: grid; grid-template-columns: 200px 1fr; gap: 1rem; align-items: start; margin-top: 1rem; }
.twofa-qr svg { width: 200px; height: 200px; background: #fff; border-radius: 10px; padding: 6px; }
@media (max-width: 560px) { .twofa-setup { grid-template-columns: 1fr; justify-items: center; } }
pre.codes { background: var(--surface2); padding: .75rem; border-radius: 8px; font-size: 1rem; line-height: 1.7; columns: 2; }
.check-list li { margin: .4rem 0; line-height: 1.45; }

/* Product photo (web) next to the user's own photo */
.img-pair { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem; margin-top: .4rem; }
.img-pair figure { margin: 0; border: 1px solid var(--border); border-radius: 8px; padding: .25rem; text-align: center; }
.img-pair figure.on { border-color: var(--brand); }
.img-pair figure > button { padding: 0; border: 0; background: none; width: 100%; }
.img-pair img { width: 100%; height: 70px; object-fit: contain; display: block; }
.img-pair figcaption { font-size: .72rem; color: var(--muted); }
button.link { border: 0; background: none; padding: 0; color: var(--brand); text-decoration: underline; font-size: inherit; cursor: pointer; }
.photo-picks { display: grid; gap: .5rem; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
.photo-pick { display: grid; gap: .25rem; padding: .35rem; background: #fff; color: #333; }
.photo-pick img { width: 100%; height: 110px; object-fit: contain; }

/* Exact bitmap sent to the Brother label printer */
.brother-preview { display: flex; flex-wrap: wrap; gap: 3mm; align-items: flex-start; margin-top: .5rem; }
.brother-preview p { flex-basis: 100%; margin: 0; }
.brother-preview canvas { height: auto; max-width: 100%; border: 1px dashed var(--border); image-rendering: pixelated; background: #fff; }

/* Parts already in stock, suggested while typing a new component */
.stock-suggest { border: 1px solid var(--border); border-radius: var(--radius); padding: .5rem .6rem; background: var(--surface2); display: grid; gap: .35rem; }
.stock-suggest[hidden] { display: none; }
.stock-hit { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.stock-hit .thumb { width: 36px; height: 36px; }
.stock-hit-txt { flex: 1; min-width: 140px; }
/* Bin page with the drawer photo: the photo shows through, the current bin is outlined */
.where .gf-grid.has-photo .gf-bin:not(.hl) { background: transparent; border-color: color-mix(in srgb, #fff 55%, transparent); color: #fff; text-shadow: 0 0 3px #000; }
.where .gf-grid.has-photo .gf-bin.hl { background: color-mix(in srgb, var(--brand) 30%, transparent); outline: 3px solid var(--brand); outline-offset: -1px; color: #fff; text-shadow: 0 0 3px #000; }
.where .gf-grid.has-photo .gf-cell { background: transparent; border-color: transparent; }

.row-actions { display: inline-flex; gap: .3rem; flex-wrap: wrap; justify-content: flex-end; }

.transfer-target select { border-color: var(--brand); }

.move-plan .gf-grid { max-width: min(100%, calc(var(--cols) * 80px)); }
.move-plan .gf-bin:not(.hl) { pointer-events: auto; opacity: 1; cursor: pointer; }
.move-plan .gf-bin:not(.hl):hover { border-color: var(--brand); }
.move-plan .gf-bin.source { opacity: .35; cursor: not-allowed; }
.move-plan .gf-cell { pointer-events: none; }

/* Plan tab: workshop seen from above, cabinet fronts with their drawers */
.pl-grid {
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  grid-template-rows: repeat(var(--rows), minmax(56px, auto));
  gap: 6px;
  padding: 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: min(100%, calc(var(--cols) * 220px));
}
.pl-grid.atelier { grid-template-rows: repeat(var(--rows), minmax(64px, 1fr)); }
.pl-cell { border: 1px dashed var(--border); border-radius: 6px; background: transparent; padding: 0; min-height: 0; min-width: 0; }
button.pl-cell { cursor: pointer; }
button.pl-cell:hover, button.pl-cell:focus-visible { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 8%, transparent); }
.pl-item {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-width: 0; padding: .3rem .4rem; text-align: center; text-decoration: none; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: 6px; overflow: hidden;
}
.pl-item:hover { border-color: var(--brand); }
.pl-item.atelier { background: color-mix(in srgb, var(--brand) 10%, var(--surface)); }
.pl-item.facade::after { content: ''; width: 34%; max-width: 64px; height: 4px; margin-top: 3px; border-radius: 2px; background: var(--muted); opacity: .45; }
.pl-item.hl, .pl-item.sel { outline: 3px solid var(--brand); outline-offset: -2px; }
.pl-name { max-width: 100%; font-weight: 600; font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pl-sub { font-size: .75rem; color: var(--muted); }
.pl-grid.compact { grid-template-rows: repeat(var(--rows), 30px); gap: 3px; padding: 4px; max-width: min(100%, calc(var(--cols) * 150px)); margin-top: .5rem; }
.pl-grid.compact .pl-item { padding: 0 .3rem; }
.pl-grid.compact .pl-item.facade::after { display: none; }
.pl-grid.compact .pl-name { font-size: .72rem; }
.plan-size { display: inline-flex; gap: .3rem; align-items: center; }
.plan-size input { width: 4.2rem; }
.plan-unplaced button { margin: .15rem 0; }

/* Cabinet front at its real proportions (width / height known) */
.pl-grid.real { grid-template-rows: repeat(var(--rows), minmax(0, 1fr)); aspect-ratio: var(--ratio); width: min(100%, calc(440px * var(--ratio))); max-width: none; }
.pl-grid.compact.real { width: min(100%, calc(200px * var(--ratio))); }
.pl-grid.real .pl-item { min-height: 0; }

/* Floor plans: rooms in cm, doors, windows, cabinets */
.fp-tools { flex-wrap: wrap; }
.fp-zoom { display: inline-flex; gap: .25rem; }
.fp-more { margin-left: auto; display: inline-flex; gap: .3rem; }
.fp-wrap { position: relative; }
.fp-svg { display: block; width: 100%; height: min(68vh, 640px); background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius); touch-action: none; user-select: none; color: var(--border); }
.fp-hint { margin: .3rem 0 .6rem; }
.fp-gridline { fill: none; stroke: currentColor; stroke-width: 1; vector-effect: non-scaling-stroke; }
.fp-import { fill: none; stroke: var(--muted); stroke-width: 1.2; vector-effect: non-scaling-stroke; pointer-events: none; }
.fp-floor { fill: color-mix(in srgb, var(--surface) 88%, transparent); }
.fp-walls { fill: none; stroke: var(--text); }
.fp-room { cursor: move; }
.fp-room.sel .fp-walls { stroke: var(--brand); }
.fp-gap { stroke: var(--surface); }
.fp-hit { stroke: transparent; cursor: ew-resize; }
.fp-leaf, .fp-glass { stroke: var(--text); stroke-width: 2; vector-effect: non-scaling-stroke; }
.fp-swing { fill: none; stroke: var(--muted); stroke-width: 1; stroke-dasharray: 4 3; vector-effect: non-scaling-stroke; }
.fp-open.sel .fp-leaf, .fp-open.sel .fp-glass, .fp-open.sel .fp-swing { stroke: var(--brand); }
.fp-item { cursor: move; }
.fp-item rect { fill: color-mix(in srgb, var(--brand) 22%, var(--surface)); stroke: var(--brand); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.fp-item.drawer rect { fill: color-mix(in srgb, var(--warn) 20%, var(--surface)); stroke: var(--warn); }
.fp-item.sel rect { stroke-width: 3.5; }
.fp-front { stroke: var(--text); stroke-width: 3; vector-effect: non-scaling-stroke; }
.fp-label { fill: var(--text); text-anchor: middle; dominant-baseline: middle; pointer-events: none; font-weight: 600; paint-order: stroke; stroke: var(--surface); stroke-width: 3px; stroke-linejoin: round; }
.fp-dim { fill: var(--muted); font-weight: 400; font-size: .82em; }
.fp-handle { fill: var(--brand); stroke: var(--surface); stroke-width: 2; vector-effect: non-scaling-stroke; cursor: nwse-resize; }
.fp-calib { fill: var(--bad); }
.fp-calib-line { stroke: var(--bad); stroke-width: 2; stroke-dasharray: 6 4; vector-effect: non-scaling-stroke; }
.fp-panel { margin-bottom: 1rem; }
.fp-fields { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
label.btn.busy { opacity: .6; pointer-events: none; }
.fp-room-label { text-anchor: start; }

/* Toast in the top layer (popover): above open windows */
#toast[popover] { inset: auto auto 1.25rem 50%; margin: 0; border: 0; overflow: visible; }
#toast[popover]:popover-open { display: block; }
/* What's wrong in a form */
.form-error { grid-column: 1 / -1; margin-top: .6rem; padding: .55rem .8rem; border-left: 4px solid var(--bad); border-radius: 0 8px 8px 0; background: color-mix(in srgb, var(--bad) 12%, var(--surface)); color: var(--text); font-weight: 600; }
label.invalid > span { color: var(--bad); font-weight: 600; }
label.invalid input, label.invalid select, label.invalid textarea { border-color: var(--bad); box-shadow: 0 0 0 2px color-mix(in srgb, var(--bad) 30%, transparent); }
.fp-item.raised rect { fill: color-mix(in srgb, var(--brand) 12%, transparent); stroke-dasharray: 6 4; }
/* Colour chosen for a cabinet or drawer */
.fp-item.colored rect { fill: color-mix(in srgb, var(--c) 38%, var(--surface)); stroke: var(--c); }
.fp-item.colored.raised rect { fill: color-mix(in srgb, var(--c) 22%, transparent); }
.pl-item.colored { border-color: var(--c); background: color-mix(in srgb, var(--c) 22%, var(--surface)); }

/* Moving storage places: drag and drop on the Rangements page, list of destinations */
.tree-node[draggable="true"] { cursor: grab; border-radius: 8px; padding: .1rem .3rem; margin-left: -.3rem; }
.tree-node.dragging { opacity: .45; }
.tree-node.drop-ok, .tree-drop-root.drop-ok { outline: 2px solid var(--brand); background: color-mix(in srgb, var(--brand) 15%, transparent); }
.tree-drop-root { margin-top: 1rem; padding: .8rem 1rem; border: 2px dashed var(--border); border-radius: var(--radius); color: var(--muted); text-align: center; }
.move-dests .sel { display: block; width: 100%; }
.move-dests .sel [data-path] { display: block; font-size: .78em; }
.move-dests .sel.current { opacity: .6; }

/* Machines */
.machine-grid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.machine-card { display: flex; gap: .8rem; align-items: flex-start; }
.machine-card img, .machine-noimg { width: 72px; height: 72px; flex: none; object-fit: cover; border-radius: 8px; background: var(--surface2); }
.machine-noimg { display: grid; place-items: center; font-size: 2rem; }
.machine-card h3 { margin: 0 0 .15rem; }
.machine-head { display: grid; grid-template-columns: minmax(0, 320px) minmax(0, 1fr); gap: 1rem; align-items: start; }
.machine-head:not(:has(.machine-photo)) { grid-template-columns: minmax(0, 1fr); }
.machine-photo { padding: 0; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface2); cursor: zoom-in; }
.machine-photo img { display: block; width: 100%; max-height: 360px; object-fit: contain; }
.machine-facts { display: grid; grid-template-columns: max-content 1fr; gap: .3rem 1rem; margin: 0 0 .6rem; }
.machine-facts dt { color: var(--muted); }
.machine-facts dd { margin: 0; font-weight: 600; }
.machine-notes { white-space: pre-wrap; margin-top: .2rem; }
@media (max-width: 640px) { .machine-head { grid-template-columns: minmax(0, 1fr); } }
.machine-link-row { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1.5fr) auto auto; gap: .4rem; margin-bottom: .4rem; }
.machine-link-row.ai-filled input { border-color: var(--brand); }
@media (max-width: 640px) { .machine-link-row { grid-template-columns: minmax(0, 1fr) auto; } .machine-link-row [data-k="url"] { grid-column: 1 / -1; grid-row: 2; } }
.machine-linklist { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: .4rem 1.2rem; }
.machine-linklist h3 { margin: .2rem 0 .3rem; font-size: 1rem; }
.machine-linklist ul { margin: 0; padding-left: 1.1rem; }
.machine-linklist li { margin: .2rem 0; }
.plan-grow { display: inline-flex; align-items: center; gap: .25rem; }
.plan-grow button { min-width: 2rem; }

/* Impression 3D */
.p3-drop-all, .p3-size, .p3-item.missing { transition: background .15s, outline-color .15s; }
.p3-drop-all { display: grid; gap: .3rem; padding: 1.1rem 1.2rem; border: 2px dashed var(--border); border-radius: var(--radius); text-align: center; cursor: pointer; margin-bottom: .8rem; }
.p3-drop-all.drop-ok, .p3-size.drop-ok, .p3-item.drop-ok { outline: 2px solid var(--brand); background: color-mix(in srgb, var(--brand) 12%, transparent); }
.p3-sizes, .p3-queue { display: grid; gap: .5rem; }
.p3-size, .p3-item { border: 1px solid var(--border); border-radius: var(--radius); padding: .6rem .8rem; background: var(--surface); }
.p3-size { cursor: pointer; }
.p3-size.missing, .p3-item.missing { border-style: dashed; border-color: color-mix(in srgb, var(--warn) 60%, var(--border)); }
.p3-size-head { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.p3-size-head [data-queue] { margin-left: auto; }
.p3-files { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; margin-top: .45rem; }
.p3-file { display: inline-flex; flex-wrap: wrap; align-items: center; gap: .35rem; padding: .25rem .4rem .25rem .6rem; border: 1px solid var(--border); border-radius: 999px; background: var(--surface2); }
.p3-file.unsliced { border-color: var(--warn); }
.p3-drop-hint { padding: .2rem .4rem; }
.p3-item { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.6fr) auto; gap: .6rem; align-items: center; }
.p3-item-main { display: flex; flex-wrap: wrap; gap: .4rem; align-items: baseline; }
.p3-item-file { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.p3-item-actions { display: flex; gap: .3rem; align-items: center; justify-content: flex-end; }
.p3-item.done { opacity: .7; }
.p3-done { margin-top: .6rem; }
.p3-done summary { cursor: pointer; margin-bottom: .5rem; }
@media (max-width: 760px) { .p3-item { grid-template-columns: minmax(0, 1fr); } .p3-item-actions { justify-content: flex-start; } }

/* Ranger un produit */
.store-best { display: grid; gap: .25rem; justify-items: start; padding: .8rem 1rem; border: 2px solid var(--brand); border-radius: var(--radius); background: color-mix(in srgb, var(--brand) 10%, var(--surface)); }
.store-best-place { font-size: 1.1rem; }
.store-best button { margin-top: .4rem; }
.store-map { width: min(100%, 320px); margin-top: .4rem; pointer-events: none; }

/* Plan du tiroir sur la page d'un bac : trois tailles */
.where-sizes { display: inline-flex; gap: .2rem; }
.where[data-size="s"] .gf-grid { max-width: 420px; }
.where[data-size="m"] .gf-grid { max-width: min(100%, 760px); }
.where[data-size="l"] .gf-grid { max-width: 100%; }
.where[data-size="m"] .gf-grid:not(.compact), .where[data-size="l"] .gf-grid:not(.compact) { pointer-events: auto; }
.nav-count { display: inline-block; min-width: 1.2rem; margin-left: .3rem; padding: 0 .35rem; border-radius: 999px; background: var(--brand); color: var(--surface); font-size: .72rem; font-weight: 700; line-height: 1.2rem; text-align: center; }
.nav-count[hidden] { display: none; }

/* Module lumineux (ESP32) : appairage par code court et QR code */
.module-pair { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; margin: .4rem 0 .8rem; }
.module-qr { width: 9rem; height: 9rem; padding: .4rem; background: #fff; border-radius: 6px; flex: none; }
.module-qr svg { width: 100%; height: 100%; display: block; }
.module-code { font-size: 2rem; font-weight: 700; letter-spacing: .12em; }
.module-leds { width: 100%; margin: .5rem 0; }
.module-leds td, .module-leds th { padding: .2rem .4rem; text-align: left; }

/* Shop barcode scanner */
.scan-view { border-radius: var(--radius); overflow: hidden; background: #000; margin: .5rem 0; position: relative; }
.scan-view video { display: block; width: 100%; max-height: 50vh; object-fit: cover; }
.scan-view::after { content: ''; position: absolute; left: 8%; right: 8%; top: 50%; border-top: 2px solid rgb(255 60 60 / .8); }
.scan-manual { display: flex; gap: .5rem; margin: .5rem 0; }
.scan-manual input { flex: 1; min-width: 0; }
.pick-list { display: grid; gap: .35rem; margin: .6rem 0; max-height: 50vh; overflow: auto; }
.pick-list button { display: grid; gap: .1rem; text-align: left; justify-items: start; }
.pick-list small { color: var(--muted); font-weight: 400; }

/* A product's own QR label */
.qr-print { display: grid; justify-items: center; gap: .3rem; padding: .8rem; background: #fff; color: #000; border-radius: var(--radius); text-align: center; }
@media print {
  body.printing-qr > *:not(dialog) { display: none !important; }
  body.printing-qr dialog { position: static; border: 0; box-shadow: none; }
  body.printing-qr dialog h2, body.printing-qr dialog p, body.printing-qr dialog .actions { display: none; }
}

/* USB barcode scanner: mode and quick add */
.scanner-mode { display: inline-flex; align-items: center; gap: .35rem; font-size: .85rem; color: var(--muted); }
.scanner-mode select { width: auto; padding: .3rem .5rem; }
.quick-qty { display: flex; align-items: center; justify-content: center; gap: 1rem; margin: .6rem 0; }
.quick-qty button { width: 2.6rem; height: 2.6rem; font-size: 1.3rem; padding: 0; }
.quick-qty output { font-size: 2rem; font-weight: 700; min-width: 3ch; text-align: center; }
