/*
VOICE  outil de terrain : sobre, lisible au soleil, gros boutons pour le doigt
IDEA   une planche de chantier posée sur l'image satellite
PICTURE la carte occupe tout l'écran ; l'interface flotte autour
COLOUR ardoise foncé + orange signalisation
TYPE   police système (native sur iPad / iPhone)
*/
:root {
  --bg: #0f172a; --bg2: #1e293b; --bg3: #334155; --ink: #f1f5f9; --mute: #94a3b8;
  --acc: #f97316; --acc2: #ea580c; --danger: #ef4444; --ok: #22c55e;
  --paper: #ffffff; --pink: #0f172a; --line: #e2e8f0;
  --r: 12px; --sh: 0 6px 24px rgba(0,0,0,.35);
  --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px); --sal: env(safe-area-inset-left, 0px); --sar: env(safe-area-inset-right, 0px);
  --top: calc(54px + var(--sat));
  color-scheme: dark;
}
* { box-sizing: border-box; min-width: 0; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--ink);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; overscroll-behavior: none; }
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea { font-size: 16px; } /* évite le zoom iOS */
svg { flex: none; }
[hidden] { display: none !important; }

/* ——— Barre du haut */
#topbar { position: fixed; inset: 0 0 auto 0; height: var(--top); padding: var(--sat) calc(8px + var(--sar)) 0 calc(8px + var(--sal));
  display: flex; align-items: center; gap: 4px; background: var(--bg); border-bottom: 1px solid #ffffff14; z-index: 1000; }
.tb { display: inline-flex; align-items: center; gap: 6px; height: 42px; min-width: 42px; padding: 0 10px; border: 0; border-radius: 10px; background: transparent; cursor: pointer; white-space: nowrap; }
.tb:hover { background: #ffffff12; } .tb:disabled { opacity: .35; cursor: default; background: transparent; }
.tb.cloud { color: var(--acc); }
#projName { width: clamp(120px, 26vw, 340px); height: 38px; border: 1px solid transparent; border-radius: 8px; background: transparent; padding: 0 8px; font-weight: 650; font-size: 16px; text-overflow: ellipsis; }
#projName:hover, #projName:focus { border-color: #ffffff2a; background: var(--bg2); outline: none; }
#saveState { display: inline-flex; color: var(--mute); transition: color .3s; }
#saveState[data-st="err"] { color: var(--danger); } #saveState[data-st="…"] { opacity: .5; } #saveState.remote { color: var(--acc); }
.spacer { flex: 1; }
.searchbox { position: relative; display: flex; align-items: center; }
#search { width: 240px; height: 38px; border-radius: 10px; border: 1px solid #ffffff22; background: var(--bg2); padding: 0 10px; }
#btnSearch { display: none; }
#searchRes { position: absolute; top: 44px; right: 0; width: min(420px, 92vw); max-height: 60vh; overflow: auto; background: var(--bg2); border-radius: var(--r); box-shadow: var(--sh); z-index: 1100; }
#searchRes button { display: block; width: 100%; text-align: left; padding: 10px 12px; border: 0; background: none; border-bottom: 1px solid #ffffff10; cursor: pointer; }
#searchRes button:hover { background: var(--bg3); }
#presence { display: flex; padding: 0 4px; }
.av { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; color: #fff; border: 2px solid var(--bg); margin-left: -6px; }
.av.more { background: var(--bg3); }

/* ——— Carte */
#mapwrap { position: fixed; inset: var(--top) 0 0 0; }
#map { position: absolute; inset: 0; background: #1f2937; }
#map.placing { cursor: crosshair; }
.leaflet-container { font: inherit; }
.leaflet-control-attribution { font-size: 10px; max-width: 60vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.leaflet-control-scale { margin-bottom: calc(10px + var(--sab)) !important; margin-left: calc(84px + var(--sal)) !important; }

/* Rail d'outils */
#rail { position: absolute; left: calc(10px + var(--sal)); top: 10px; display: flex; flex-direction: column; gap: 6px; z-index: 800; }
.rb { width: 64px; height: 58px; border: 0; border-radius: 12px; background: var(--bg); color: var(--ink); box-shadow: var(--sh); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11px; cursor: pointer; }
.rb:hover { background: var(--bg2); }
.rb.primary { background: var(--acc); color: #fff; } .rb.primary.on, .rb.primary:hover { background: var(--acc2); }
#mapctl { position: absolute; right: calc(10px + var(--sar)); top: 10px; display: flex; flex-direction: column; gap: 6px; z-index: 800; align-items: flex-end; }
#zoomctl { position: absolute; right: calc(10px + var(--sar)); bottom: calc(24px + var(--sab)); display: flex; flex-direction: column; gap: 6px; z-index: 800; }
.mc { min-width: 46px; height: 46px; border: 0; border-radius: 12px; background: var(--bg); color: var(--ink); box-shadow: var(--sh); display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 0 12px; cursor: pointer; font-size: 13px; }
.mc:hover, .mc.on { background: var(--bg2); } .mc.on { outline: 2px solid var(--acc); }
.mc small { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--mute); }
#phaseBtn { font-weight: 600; }
body.panel-open #mapctl, body.panel-open #zoomctl { right: calc(390px + var(--sar)); }

/* Bannière de mode */
#banner { position: fixed; left: 50%; transform: translateX(-50%); top: calc(var(--top) + 10px); z-index: 990; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center;
  background: var(--bg); border: 2px solid var(--acc); border-radius: 14px; padding: 8px 8px 8px 14px; box-shadow: var(--sh); max-width: min(680px, calc(100vw - 180px)); }
.bmsg { display: flex; align-items: center; gap: 8px; } .bact { display: flex; gap: 6px; }

/* Comparaison */
#swipe { position: absolute; inset: 0; pointer-events: none; z-index: 450; }
#swipeBar { position: absolute; top: 0; bottom: 0; width: 0; border-left: 3px solid #fff; box-shadow: 0 0 8px #000a; }
#swipeBar button { pointer-events: auto; position: absolute; top: 50%; left: -25px; width: 48px; height: 48px; border-radius: 50%; border: 0; background: #fff; color: #111; box-shadow: var(--sh); cursor: ew-resize; display: grid; place-items: center; touch-action: none; }
#swipeBar span { position: absolute; top: 14px; white-space: nowrap; background: #000b; color: #fff; padding: 3px 8px; border-radius: 6px; font-size: 12px; }
#swipeLabelL { right: 10px; } #swipeLabelR { left: 10px; }

/* ——— Marqueurs */
.pinwrap { background: none; border: 0; }
.pin { width: var(--s); height: var(--s); border-radius: 50%; background: var(--c); color: #fff; display: grid; place-items: center; border: 2px solid #fff; box-shadow: 0 2px 6px #0007; position: relative; transition: transform .12s; }
.pin.sel { outline: 3px solid var(--acc); outline-offset: 2px; transform: scale(1.12); }
.pin .qty { position: absolute; right: -10px; top: -8px; background: #111; color: #fff; font-size: 10px; line-height: 1; padding: 3px 4px; border-radius: 8px; border: 1px solid #fff; font-style: normal; }
.pin .dot { position: absolute; right: -2px; bottom: -2px; width: 10px; height: 10px; border-radius: 50%; background: #f59e0b; border: 2px solid #fff; }
.leaflet-tooltip.lbl { background: #ffffffee; color: #111; border: 0; box-shadow: 0 1px 4px #0005; padding: 1px 6px; font-size: 11.5px; font-weight: 600; border-radius: 4px; white-space: nowrap; }
.leaflet-tooltip.lbl::before { display: none; }
.leaflet-tooltip.lbl.zone { background: #0f172acc; color: #fff; font-size: 12px; }
.leaflet-tooltip.lbl.meas { background: #111; color: #fff; }
.txtwrap { background: none; border: 0; width: 0 !important; height: 0 !important; }
.txt { position: absolute; white-space: pre; font-weight: 750; line-height: 1.1; text-shadow: 0 0 3px #fff, 0 0 3px #fff, 0 0 6px #fff; cursor: pointer; transform-origin: center; }
.txt.sel { outline: 2px dashed var(--acc); outline-offset: 4px; }
.arrowhead { background: none; border: 0; }
.hdl { background: none; border: 0; }
.hdl > svg, .hdl { display: grid; place-items: center; }
.hdl.rot, .hdl.mv, .hdl.corner { width: 30px; height: 30px; }
.hdl.rot::before, .hdl.mv::before, .hdl.corner::before { content: ""; position: absolute; inset: 2px; border-radius: 50%; background: #fff; border: 2px solid var(--acc); box-shadow: 0 2px 6px #0006; z-index: -1; }
.hdl svg { color: var(--acc2); position: relative; }
.leaflet-marker-draggable { cursor: move; }

/* ——— Tiroirs / panneaux */
.drawer { position: fixed; top: var(--top); bottom: 0; width: 380px; background: var(--bg); z-index: 950; display: flex; flex-direction: column; box-shadow: var(--sh); transition: transform .22s ease; }
#catalog { left: calc(84px + var(--sal)); width: 360px; transform: translateX(calc(-100% - 100px)); border-radius: 0 0 14px 0; }
#panel { right: 0; transform: translateX(105%); padding-right: var(--sar); }
#catalog.open, #panel.open { transform: none; }
.dhead { display: flex; align-items: center; gap: 8px; padding: 10px 10px 10px 14px; border-bottom: 1px solid #ffffff14; }
.dhead h3 { flex: 1; margin: 0; font-size: 16px; display: flex; align-items: center; gap: 8px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
#catSearch { flex: 1; height: 42px; border-radius: 10px; border: 1px solid #ffffff22; background: var(--bg2); padding: 0 12px; }
#catList, #panelBody { overflow: auto; flex: 1; padding: 12px 14px calc(24px + var(--sab)); -webkit-overflow-scrolling: touch; }
#catList section { margin-bottom: 16px; }
#catList h4 { margin: 4px 0 8px; font-size: 12px; color: var(--mute); display: flex; align-items: center; gap: 8px; font-weight: 600; }
#catList h4::before { content: ""; width: 10px; height: 10px; border-radius: 3px; background: var(--c); }
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.tile { border: 1px solid #ffffff14; background: var(--bg2); border-radius: 10px; padding: 8px 4px 6px; display: flex; flex-direction: column; align-items: center; gap: 4px; cursor: pointer; text-align: center; min-height: 86px; }
.tile:hover { border-color: var(--acc); }
.tile .tn { font-size: 11.5px; line-height: 1.2; }
.tile small { font-size: 9.5px; color: var(--mute); }
.ti { width: 34px; height: 34px; border-radius: 50%; background: var(--c); color: #fff; display: inline-grid; place-items: center; flex: none; }
.ti.sm { width: 20px; height: 20px; vertical-align: middle; }
.dhead .ti { width: 28px; height: 28px; }

/* ——— Formulaires */
.stack { display: flex; flex-direction: column; gap: 12px; }
fieldset { border: 0; padding: 0; margin: 0; }
.fld { display: flex; flex-direction: column; gap: 5px; }
.fld > span { font-size: 12px; color: var(--mute); font-weight: 600; }
.fld input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=color]), .fld select, .fld textarea, .row > input, .row > select, .stack > input, form input[type=email], form input[name=code] {
  width: 100%; min-height: 42px; border-radius: 9px; border: 1px solid #ffffff22; background: var(--bg2); padding: 8px 10px; }
.fld textarea { resize: vertical; }
:focus-visible { outline: 2px solid var(--acc); outline-offset: 1px; }
input[type=range] { width: 100%; accent-color: var(--acc); min-height: 32px; }
input[type=color] { width: 54px; height: 40px; border: 0; background: none; padding: 0; }
input[type=checkbox], input[type=radio] { width: 20px; height: 20px; accent-color: var(--acc); }
.grid2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.row { display: flex; gap: 8px; align-items: center; } .row.wrap { flex-wrap: wrap; } .row.end { justify-content: flex-end; }
.grow { flex: 1; } .w70 { width: 74px !important; flex: none; } .w90 { width: 100px !important; }
.chk { display: flex; align-items: center; gap: 10px; min-height: 36px; cursor: pointer; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { position: relative; } .chip input { position: absolute; opacity: 0; }
.chip span { display: inline-block; padding: 8px 12px; border-radius: 99px; background: var(--bg2); border: 1px solid #ffffff22; cursor: pointer; font-size: 13px; }
.chip input:checked + span { background: var(--acc); border-color: var(--acc); color: #fff; }
.chip input:focus-visible + span { outline: 2px solid #fff; }
.seg { display: flex; background: var(--bg2); border-radius: 10px; padding: 3px; gap: 3px; flex-wrap: wrap; }
.seg button, .seg label { flex: 1; border: 0; background: none; padding: 8px 10px; border-radius: 8px; cursor: pointer; font-size: 13px; display: flex; align-items: center; justify-content: center; gap: 6px; }
.seg .on { background: var(--acc); color: #fff; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 42px; padding: 0 14px; border-radius: 10px; border: 1px solid #ffffff22; background: var(--bg2); color: var(--ink); cursor: pointer; text-decoration: none; font-size: 14px; white-space: nowrap; }
.btn:hover { background: var(--bg3); } .btn:disabled { opacity: .5; }
.btn.sm { min-height: 36px; padding: 0 10px; font-size: 13px; }
.btn.primary { background: var(--acc); border-color: var(--acc); color: #fff; } .btn.primary:hover { background: var(--acc2); }
.btn.danger { color: #fecaca; border-color: #ef444466; } .btn.danger:hover { background: #7f1d1d; }
.btn.ghost { background: none; }
.btn.big { min-height: 54px; justify-content: flex-start; font-size: 15px; white-space: normal; text-align: left; }
.ib { width: 40px; height: 40px; border: 0; border-radius: 9px; background: none; display: inline-grid; place-items: center; cursor: pointer; flex: none; color: inherit; }
.ib:hover { background: #ffffff14; }
.muted { color: var(--mute); } .small { font-size: 12.5px; } .pad { padding: 12px; }
.note { background: #f9731622; border: 1px solid #f9731655; padding: 8px 10px; border-radius: 9px; font-size: 13px; display: flex; gap: 6px; align-items: center; margin: 0; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: 6px; }
.kpis > div { background: var(--bg2); border-radius: 10px; padding: 8px 10px; display: flex; flex-direction: column; }
.kpis b { font-size: 18px; font-variant-numeric: tabular-nums; white-space: nowrap; } .kpis span { font-size: 11.5px; color: var(--mute); }
.actions { border-top: 1px solid #ffffff14; padding-top: 12px; }
h4 { margin: 8px 0 0; font-size: 13px; display: flex; gap: 6px; align-items: center; }

.photos { display: flex; flex-wrap: wrap; gap: 6px; }
.photos figure { margin: 0; position: relative; }
.photos img { width: 76px; height: 76px; object-fit: cover; border-radius: 8px; cursor: zoom-in; display: block; }
.photos .x, .comments .x { position: absolute; top: 2px; right: 2px; width: 26px; height: 26px; border-radius: 50%; border: 0; background: #000a; color: #fff; display: grid; place-items: center; cursor: pointer; }
.addph { width: 76px; height: 76px; border-radius: 8px; border: 1px dashed #ffffff44; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; cursor: pointer; color: var(--mute); }
.comments { list-style: none; margin: 0 0 6px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.comments li:not(.muted) { background: var(--bg2); border-radius: 10px; padding: 8px 10px; position: relative; }
.comments p { margin: 2px 0 0; white-space: pre-wrap; }
.cm-h { display: flex; gap: 8px; align-items: baseline; padding-right: 26px; } .cm-h time { font-size: 11px; color: var(--mute); }
.comments .x { top: 6px; right: 6px; width: 24px; height: 24px; background: none; color: var(--mute); }

.layers, .imgs, .projects, .members { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.layers li, .imgs li, .members li { display: flex; align-items: center; gap: 4px; background: var(--bg2); border-radius: 10px; padding: 2px 4px 2px 2px; }
.layers li input { flex: 1; border: 0; background: none; min-height: 38px; padding: 0 6px; border-radius: 6px; }
.layers li input:focus { background: var(--bg); outline: none; }
.layers small { color: var(--mute); padding: 0 6px; font-variant-numeric: tabular-nums; }
.imgs input[type=range] { width: 90px; }
.members li { padding: 6px 6px 6px 12px; }
.projects li { display: flex; align-items: center; gap: 4px; background: var(--bg2); border-radius: 10px; }
.projects li.cur { outline: 2px solid var(--acc); }
.projects .pj { flex: 1; text-align: left; border: 0; background: none; padding: 10px 12px; cursor: pointer; display: flex; flex-direction: column; }
.projects .pj small { color: var(--mute); }
.bmlist { display: flex; flex-direction: column; gap: 4px; }
.bm { text-align: left; border: 1px solid #ffffff14; background: var(--bg2); padding: 10px 12px; border-radius: 9px; cursor: pointer; display: flex; justify-content: space-between; gap: 8px; }
.bm.on { border-color: var(--acc); background: #f9731622; }
.bm small { color: var(--mute); font-size: 11px; }
.links .btn { flex: 1 1 auto; }

table.inv { width: 100%; border-collapse: collapse; font-size: 13px; }
.inv th { text-align: left; font-size: 11.5px; color: var(--mute); font-weight: 600; padding: 4px; border-bottom: 1px solid #ffffff22; }
.inv td { padding: 6px 4px; border-bottom: 1px solid #ffffff10; vertical-align: middle; }
.inv tr.cat td { color: var(--acc); font-weight: 700; font-size: 12px; padding-top: 12px; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 650; }

/* ——— Modale */
#modal { position: fixed; inset: 0; background: #000a; z-index: 3000; display: grid; place-items: center; padding: calc(12px + var(--sat)) 12px calc(12px + var(--sab)); }
.mbox { width: min(480px, 100%); max-height: 100%; background: var(--bg); border-radius: 16px; box-shadow: var(--sh); display: flex; flex-direction: column; overflow: hidden; border: 1px solid #ffffff1a; }
#modal.wide .mbox { width: min(720px, 100%); }
#modalBody { padding: 14px 16px 18px; overflow: auto; }
#modalBody p { margin: 0; }

/* ——— Notification */
#toast { position: fixed; left: 50%; bottom: calc(24px + var(--sab)); transform: translate(-50%, 140%); background: #111827; color: #fff; padding: 10px 16px; border-radius: 12px; box-shadow: var(--sh); z-index: 3100; transition: transform .25s; max-width: min(520px, 92vw); text-align: center; border: 1px solid #ffffff22; pointer-events: none; }
#toast.on { transform: translate(-50%, 0); }

/* ——— Mise en page d'impression */
#printView { position: fixed; inset: 0; z-index: 1500; background: #0b1120; display: flex; flex-direction: column; }
#pvBar { display: flex; align-items: center; gap: 6px; padding: calc(6px + var(--sat)) calc(10px + var(--sar)) 6px calc(10px + var(--sal)); background: var(--bg); border-bottom: 1px solid #ffffff14; flex-wrap: wrap; }
#pvBar .hint { color: var(--mute); font-size: 13px; }
#pvMain { flex: 1; display: flex; min-height: 0; }
#pvForm { width: 300px; overflow: auto; padding: 14px 14px calc(20px + var(--sab)); border-right: 1px solid #ffffff14; flex: none; }
#printView.formhidden #pvForm { display: none; }
#pvStage { flex: 1; overflow: hidden; position: relative; }
#printView.busy #pvStage::after { content: "Préparation de l'export…"; position: absolute; inset: 0; display: grid; place-items: center; background: #000a; color: #fff; font-size: 18px; }

.sheet { --u: 3.78px; transform-origin: 0 0; background: var(--paper); color: #111; position: relative; box-shadow: 0 10px 40px #000; font-family: "Helvetica Neue", Arial, sans-serif; }
.sheet .frame { position: absolute; inset: calc(var(--u) * 7); border: calc(var(--u) * .5) solid #111; display: flex; }
.sheet.block-right .frame { flex-direction: row; } .sheet.block-bottom .frame { flex-direction: column; }
.sheet .mapcell { position: relative; flex: 1; overflow: hidden; }
#pvSlot { position: absolute; inset: 0; }
#pvSlot #map { position: absolute; inset: 0; }
.sheet .north { position: absolute; top: calc(var(--u) * 5); right: calc(var(--u) * 5); width: calc(var(--u) * 11); height: calc(var(--u) * 15); z-index: 800; pointer-events: none; }
.sheet .pscale { position: absolute; left: calc(var(--u) * 5); bottom: calc(var(--u) * 5); z-index: 800; background: #ffffffe6; padding: calc(var(--u) * 1.5) calc(var(--u) * 3) calc(var(--u) * 1); border-radius: calc(var(--u) * 1); pointer-events: none; }
.pscale .bar { display: flex; height: calc(var(--u) * 1.8); border: calc(var(--u) * .3) solid #111; }
.pscale .bar i { flex: 1; } .pscale .bar i:nth-child(odd) { background: #111; }
.pscale .lbls { display: flex; justify-content: space-between; font-size: calc(var(--u) * 2.6); font-weight: 700; margin-top: calc(var(--u) * .5); }
.sheet .tblock { flex: none; background: #fff; display: flex; flex-direction: column; font-size: calc(var(--u) * 2.6); line-height: 1.3; overflow: hidden; }
.sheet.block-right .tblock { width: calc(var(--u) * 68); border-left: calc(var(--u) * .5) solid #111; }
.sheet.block-bottom .tblock { height: calc(var(--u) * 48); border-top: calc(var(--u) * .5) solid #111; flex-direction: row; }
.tblock > div { padding: calc(var(--u) * 3); border-bottom: calc(var(--u) * .25) solid #111; }
.sheet.block-bottom .tblock > div { border-bottom: 0; border-right: calc(var(--u) * .25) solid #111; }
.tb-logo { display: grid; place-items: center; } .tb-logo img { max-width: 100%; max-height: calc(var(--u) * 18); }
.tb-title h2 { margin: 0; font-size: calc(var(--u) * 5); line-height: 1.1; }
.tb-title p { margin: calc(var(--u) * 1) 0 0; font-size: calc(var(--u) * 3); }
.tb-title .phase { font-weight: 700; color: #c2410c; }
.tb-legend { flex: 1; min-height: 0; overflow: hidden; }
.sheet.block-bottom .tb-legend { flex: 2; }
.tblock h5 { margin: 0 0 calc(var(--u) * 1.5); font-size: calc(var(--u) * 2.8); text-transform: none; }
.tb-legend ul { list-style: none; margin: 0; padding: 0; columns: 1; }
.sheet.block-bottom .tb-legend ul { columns: 3; }
.sheet.block-right .tb-legend ul { columns: 1; }
.tb-legend li { display: flex; align-items: center; gap: calc(var(--u) * 1.5); break-inside: avoid; padding: calc(var(--u) * .45) 0; }
.tb-legend li > span:nth-child(2) { flex: 1; } .tb-legend small { color: #555; }
.tb-legend em { font-style: normal; font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tb-legend .sw { width: calc(var(--u) * 5); height: calc(var(--u) * 3.4); flex: none; }
.tb-legend .sw.pin { width: calc(var(--u) * 3.6); height: calc(var(--u) * 3.6); border-radius: 50%; display: grid; place-items: center; }
.tb-legend .sw.pin svg { width: 70%; height: 70%; }
.tb-legend .sw.box { border-radius: calc(var(--u) * .5); }
.tb-notes p { margin: 0; }
.tb-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0; padding: 0 !important; }
.sheet.block-bottom .tb-grid { flex: 1.3; }
.tb-row { padding: calc(var(--u) * 1.2) calc(var(--u) * 2); border-bottom: calc(var(--u) * .2) solid #999; border-right: calc(var(--u) * .2) solid #999; display: flex; flex-direction: column; }
.tb-row span { font-size: calc(var(--u) * 2); color: #555; text-transform: uppercase; letter-spacing: .02em; }
.tb-row b { font-size: calc(var(--u) * 2.8); }
.tb-row.src { grid-column: 1 / -1; } .tb-row.src b { font-weight: 500; font-size: calc(var(--u) * 2.2); }
.muted { color: var(--mute); }
.sheet .muted { color: #777; }
body.capturing .sheet { box-shadow: none; }
.sheet .leaflet-control-container { display: none; }

@media print {
  @page { margin: 0; }
  html, body { background: #fff !important; height: auto; overflow: visible; }
  body > *:not(#printView) { display: none !important; }
  #printView { position: static; background: #fff; display: block; }
  #pvBar, #pvForm { display: none !important; }
  #pvMain, #pvStage { display: block; overflow: visible; }
  .sheet { box-shadow: none; margin: 0 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ——— Tablette & téléphone */
@media (max-width: 1100px) { .tb .lb { display: none; } #search { width: 190px; } }
@media (max-width: 760px) {
  :root { --top: calc(52px + var(--sat)); }
  #projName { width: auto; flex: 1; }
  .spacer { display: none; }
  #btnSearch { display: inline-flex; }
  .searchbox #search { display: none; }
  .searchbox.open { position: fixed; left: 8px; right: 8px; top: calc(6px + var(--sat)); z-index: 1200; }
  .searchbox.open #search { display: block; width: 100%; } .searchbox.open #btnSearch { display: none; }
  .searchbox.open #searchRes { width: 100%; }
  #btnSettings, #btnRedo, #presence { display: none; }
  .tb { padding: 0 8px; min-width: 40px; }
  .drawer { top: auto; bottom: 0; left: 0 !important; right: 0 !important; width: 100%; max-height: 62vh; height: 62vh; border-radius: 18px 18px 0 0; transform: translateY(105%) !important; padding: 0 var(--sar) 0 var(--sal); }
  #catalog.open, #panel.open { transform: none !important; }
  #catalog, #panel { width: 100%; border-radius: 18px 18px 0 0; }
  .drawer .dhead::before { content: ""; position: absolute; left: 50%; top: 5px; width: 40px; height: 4px; border-radius: 4px; background: #ffffff44; transform: translateX(-50%); }
  .drawer .dhead { position: relative; padding-top: 14px; }
  .tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .tile { min-height: 78px; } .tile small { display: none; }
  #rail { top: auto; bottom: calc(14px + var(--sab)); left: 50%; transform: translateX(-50%); flex-direction: row; gap: 4px; background: var(--bg); padding: 4px; border-radius: 16px; box-shadow: var(--sh); }
  .rb { width: 54px; height: 52px; box-shadow: none; font-size: 10px; }
  #zoomctl { bottom: calc(90px + var(--sab)); }
  #zoomctl #btnZoomIn, #zoomctl #btnZoomOut { display: none; }
  #mapctl .mc small { display: none; }
  body.panel-open #mapctl, body.panel-open #zoomctl { right: calc(10px + var(--sar)); }
  #banner { top: calc(var(--top) + 8px); max-width: calc(100vw - 16px); font-size: 13px; }
  .leaflet-control-scale { margin-left: calc(10px + var(--sal)) !important; margin-bottom: calc(84px + var(--sab)) !important; }
  .leaflet-control-attribution { display: none; }
  #pvForm { position: absolute; z-index: 5; inset: 0 0 0 auto; width: min(320px, 90vw); background: var(--bg); }
  #pvBar .hint { display: none; }
  .grid2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}
@media (max-width: 400px) { .rb span:last-child { display: none; } .rb { width: 46px; height: 46px; } }
@media (prefers-reduced-motion: reduce) { .drawer, #toast, .pin { transition: none; } }
body.capturing .sheet, body.capturing #map, body.capturing .leaflet-container, body.capturing #pvSlot, body.capturing .mapcell { background: transparent !important; }

/* ——— Catalogue par catégories */
.catmeta { display: flex; gap: 12px; align-items: center; padding: 6px 14px; border-bottom: 1px solid #ffffff10; }
.catmeta small { flex: 1; color: var(--mute); }
.linkbtn { background: none; border: 0; color: var(--acc); cursor: pointer; font-size: 13px; padding: 6px 0; }
details.catsec { border-bottom: 1px solid #ffffff10; }
details.catsec > summary, #catList h4 { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px; padding: 12px 2px; font-weight: 650; font-size: 14px; color: var(--ink); }
details.catsec > summary::-webkit-details-marker { display: none; }
details.catsec > summary::before, #catList h4::before { content: ""; width: 12px; height: 12px; border-radius: 4px; background: var(--c); flex: none; }
details.catsec > summary span { flex: 1; }
details.catsec > summary small { color: var(--mute); font-weight: 500; }
details.catsec > summary::after { content: "›"; font-size: 20px; color: var(--mute); transition: transform .15s; }
details.catsec[open] > summary::after { transform: rotate(90deg); }
details.catsec .tiles { padding-bottom: 12px; }
#catList section.recent { margin-bottom: 4px; padding-bottom: 8px; border-bottom: 1px solid #ffffff10; }

/* ——— Formes de pictogrammes */
.pin { border: 2px solid var(--b, #fff); }
.pin .pi { display: grid; place-items: center; }
.pin.s-square { border-radius: 22%; }
.pin.s-diamond { border-radius: 12%; transform: rotate(45deg) scale(.86); }
.pin.s-diamond .pi { transform: rotate(-45deg); }
.pin.s-diamond.sel { transform: rotate(45deg) scale(.96); }
.pin.s-shield { border-radius: 14% 14% 50% 50% / 14% 14% 60% 60%; }
.pin.s-icon { background: none; border: 0; box-shadow: none; filter: drop-shadow(0 0 1.5px #fff) drop-shadow(0 0 1.5px #fff) drop-shadow(0 1px 2px #0006); }
.leaflet-tooltip.lbl-dark { background: #0f172ae6; color: #fff; }
.leaflet-tooltip.lbl-plain { background: none; box-shadow: none; color: #111; text-shadow: 0 0 3px #fff, 0 0 3px #fff, 0 0 5px #fff; }
.txt { text-shadow: none; }

/* ——— Apparence */
details.appear { background: #ffffff08; border: 1px solid #ffffff14; border-radius: 12px; padding: 0 12px; }
details.appear > summary { cursor: pointer; padding: 12px 0; font-weight: 650; display: flex; align-items: center; gap: 8px; list-style: none; }
details.appear > summary::-webkit-details-marker { display: none; }
details.appear[open] { padding-bottom: 12px; }
.fld output { float: right; color: var(--ink); font-variant-numeric: tabular-nums; font-weight: 500; }
.palette { display: flex; flex-wrap: wrap; gap: 6px; }
.palette button { width: 28px; height: 28px; border-radius: 8px; border: 2px solid #ffffff33; cursor: pointer; }
.palette button:hover { transform: scale(1.1); border-color: #fff; }
.patterns { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.patterns button { background: #fff; border: 2px solid transparent; border-radius: 9px; padding: 6px 4px 4px; display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer; color: #334155; }
.patterns button small { font-size: 10px; line-height: 1.1; text-align: center; }
.patterns button.on { border-color: var(--acc); box-shadow: 0 0 0 2px #f9731655; }
.colf input[type=color] { width: 100%; height: 40px; border-radius: 9px; }
.stylebtns .btn { flex: 1 1 auto; }
.seg button { white-space: nowrap; }
.tb-legend .sw svg { width: 100%; height: 100%; display: block; }
.tb-legend .sw.pinw { width: calc(var(--u) * 5); display: grid; place-items: center; }
.tb-legend .sw.pinw .pin { border-width: 1px; box-shadow: none; }
.sheet .wm { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; z-index: 790; overflow: hidden; }
.sheet .wm span { transform: rotate(-28deg); font: 800 calc(var(--u) * 16)/1 Helvetica, Arial, sans-serif; color: #ffffff70; -webkit-text-stroke: calc(var(--u) * .25) #00000040; white-space: nowrap; }

/* ——— Comptes & forfaits */
#announce { position: fixed; top: var(--top); left: 50%; transform: translateX(-50%); z-index: 960; background: #f97316; color: #fff; font-size: 13px; font-weight: 600; padding: 6px 8px 6px 14px; border-radius: 0 0 12px 12px; display: flex; align-items: center; gap: 10px; box-shadow: var(--sh); max-width: calc(100vw - 20px); }
#announce .linkbtn { color: #fff; text-decoration: underline; font-weight: 700; }
#announce .ib { width: 28px; height: 28px; }
#btnAccount .av.me { margin: 0; width: 32px; height: 32px; border: 0; }
.viewer-badge { display: none; align-items: center; gap: 6px; background: #f9731633; color: #fdba74; padding: 6px 10px; border-radius: 99px; font-size: 13px; font-weight: 600; }
body.viewer .viewer-badge { display: inline-flex; }
body.viewer #rail, body.viewer #btnUndo, body.viewer #btnRedo, body.viewer #btnShare, body.viewer #btnProjects, body.viewer #saveState, body.viewer #btnSettings { display: none !important; }
.btn.locked { border-style: dashed; color: #fdba74; justify-content: flex-start; white-space: normal; text-align: left; }
.appear.locked { padding: 0; }
.appear.locked .btn { width: 100%; }

#auth { position: fixed; inset: 0; z-index: 2500; display: grid; place-items: center; padding: calc(16px + var(--sat)) 16px calc(16px + var(--sab)); overflow: auto; }
.authbg { position: fixed; inset: 0; background: radial-gradient(1200px 600px at 20% 10%, #f9731633, transparent 60%), linear-gradient(160deg, #0f172aee, #020617f5); backdrop-filter: blur(3px); }
.authcard { position: relative; width: min(440px, 100%); background: var(--bg); border: 1px solid #ffffff1f; border-radius: 20px; padding: 26px 24px 20px; box-shadow: 0 30px 80px #000a; }
.authcard .brand { display: flex; align-items: center; gap: 10px; color: var(--acc); font-size: 20px; }
.authcard .brand b { color: var(--ink); }
.authcard h1 { margin: 18px 0 4px; font-size: 26px; line-height: 1.15; }
.authcard > p { margin: 0 0 16px; }
.authlinks { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 14px; }
.note.ok { background: #16a34a22; border-color: #16a34a66; }
body.authing #topbar, body.authing #rail, body.authing #mapctl, body.authing #zoomctl { filter: blur(2px); }

#modal.xl .mbox { width: min(1180px, 100%); }
.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; }
.plan { position: relative; background: var(--bg2); border: 1px solid #ffffff1a; border-radius: 16px; padding: 18px 16px; display: flex; flex-direction: column; gap: 10px; }
.plan.hl { border: 2px solid var(--acc); }
.plan.cur { outline: 2px solid #22c55e; }
.plan h3 { margin: 0; font-size: 19px; } .plan p { margin: 0; }
.plan .price b { font-size: 30px; font-variant-numeric: tabular-nums; } .plan .price span { display: block; color: var(--mute); font-size: 12.5px; }
.plan ul { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.plan li { display: flex; gap: 6px; align-items: flex-start; } .plan li svg { color: #22c55e; margin-top: 2px; }
.ribbon { position: absolute; top: -11px; right: 14px; background: var(--acc); color: #fff; font-size: 11px; font-weight: 700; padding: 3px 10px; border-radius: 99px; }
.seg.billing { max-width: 420px; }
.upsell { text-align: center; align-items: center; }
.upsell .upic { width: 58px; height: 58px; border-radius: 50%; background: #f9731622; color: var(--acc); display: grid; place-items: center; }
.upsell .row { width: 100%; }
.usage { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.usage .meter { flex: 1; height: 8px; background: #ffffff14; border-radius: 99px; overflow: hidden; }
.usage .meter i { display: block; height: 100%; background: var(--acc); border-radius: 99px; }
.acct-plan { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; background: var(--bg2); border-radius: 14px; padding: 14px; }
.acct-plan > div:first-child { display: flex; flex-direction: column; }
.acct-plan b { font-size: 20px; }
.tag { font-size: 12px; color: #86efac; }
@media (max-width: 760px) { #announce { left: 8px; right: 8px; transform: none; max-width: none; border-radius: 0 0 12px 12px; } }
