/* FORMAXIS — By Ortopedica Scaligera
   Stile minimale, piatto. Tema scuro (predefinito) e chiaro. */

:root, [data-theme="dark"] {
  --accent: #F39200;
  --accent-hover: #FFA21F;
  --accent-soft: rgba(243, 146, 0, .12);
  --on-accent: #1A1204;

  --bg: #0E1014;
  --surface: #16191F;
  --surface-2: #1D2128;
  --field: #111318;
  --line: #262A32;
  --line-strong: #353A44;
  --text: #ECEEF1;
  --text-2: #9AA1AC;
  --text-3: #868D99;   /* AA: ≥4.5:1 sui fondi scuri (prima #6B727D ≈ 3.4:1, testi secondari troppo tenui) */

  --ok: #34C98A;
  --warn: #F5B342;
  --err: #F05D5D;

  --plan-bg: #111318;
  --plan-grid: rgba(255, 255, 255, .04);
  --plan-line: #E4E7EB;
  --plan-dim: rgba(228, 231, 235, .3);
  --plan-base: #1D2128;
  --plan-zone: rgba(154, 167, 180, .7);
  --cp-fill: #16191F;
  --engr: rgba(236, 238, 241, .85);
  --legend-bg: rgba(22, 25, 31, .92);
  --tip-bg: #262A32;
  --overlay: rgba(0, 0, 0, .55);
  color-scheme: dark;
}
[data-theme="light"] {
  --accent: #E88A00;
  --accent-hover: #F39200;
  --accent-soft: rgba(243, 146, 0, .12);
  --on-accent: #FFFFFF;

  --bg: #F4F5F7;
  --surface: #FFFFFF;
  --surface-2: #F7F8FA;
  --field: #FFFFFF;
  --line: #E3E5E9;
  --line-strong: #D0D4DA;
  --text: #1C1F24;
  --text-2: #5F6670;
  --text-3: #686E78;   /* AA: ≥4.5:1 su fondi chiari (prima #8C929B ≈ 3:1) */

  --ok: #1E9E68;
  --warn: #C98410;
  --err: #D64545;

  --plan-bg: #FAFBFC;
  --plan-grid: rgba(0, 0, 0, .045);
  --plan-line: #2A2F36;
  --plan-dim: rgba(42, 47, 54, .3);
  --plan-base: #EEF0F3;
  --plan-zone: rgba(112, 112, 112, .7);
  --cp-fill: #FFFFFF;
  --engr: rgba(28, 31, 36, .85);
  --legend-bg: rgba(255, 255, 255, .94);
  --tip-bg: #2A2F36;
  --overlay: rgba(20, 24, 30, .35);
  color-scheme: light;
}
:root {
  --relief: #4A8FE0;
  --notte: var(--text);   /* usata dal codice (plan2d.js, legenda) */
  --muted: var(--text-2);   /* icona del piano di correzione AFO (busto.css .afo-mico-w): prima non definita, ripiegava sul colore del genitore (.lbl = --text-2) */
  --sb-w: 350px;   /* larghezza della colonna laterale (tutti i moduli) */
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  font-feature-settings: "tnum" 1;
  color: var(--text);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text); }
button, input, select { font: inherit; color: inherit; }
::selection { background: var(--accent); color: var(--on-accent); }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- Barra superiore ---------- */
.topbar {
  height: 56px; display: flex; align-items: center; gap: 12px; padding: 0 16px;
  background: var(--surface); border-bottom: 1px solid var(--line); position: relative; z-index: 30; box-shadow: 0 2px 10px rgba(0,0,0,.05);   /* i menu a tendina restano sopra a tutta la pagina, sotto dialoghi e avvisi */
}
.brand { display: flex; align-items: center; gap: 10px; margin-right: 6px; text-decoration: none; }
.brand img { height: 26px; display: block; }
[data-theme="light"] .logo-dark, :root:not([data-theme="light"]) .logo-light { display: none !important; }
.steps { display: flex; gap: 6px; flex: 1; justify-content: center; }
.foot-tab {
  display: flex; align-items: center; gap: 8px; padding: 5px 10px 5px 6px; border-radius: 6px;
  background: transparent; border: 1px solid var(--line); cursor: pointer; font-size: 13px; white-space: nowrap; color: var(--text-2);
}
.foot-tab:hover { color: var(--text); border-color: var(--line-strong); }
.foot-tab.active { color: var(--text); border-color: var(--accent); background: var(--accent-soft); }
.foot-tab .side { font-weight: 700; font-size: 11px; padding: 2px 6px; border-radius: 4px; background: var(--accent); color: var(--on-accent); }
.foot-tab .x { opacity: .5; font-size: 15px; padding: 0 2px; }
.foot-tab .x:hover { opacity: 1; color: var(--err); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 6px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); cursor: pointer; font-size: 13px; font-weight: 500; white-space: nowrap;
  transition: background-color .14s, border-color .14s, color .14s, box-shadow .14s;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: linear-gradient(180deg, var(--accent-hover), var(--accent)); border-color: var(--accent); color: var(--on-accent); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.2), inset 0 1px 0 rgba(255,255,255,.18); }
.btn.primary:hover { background: linear-gradient(180deg, var(--accent-hover), var(--accent-hover)); border-color: var(--accent-hover); box-shadow: 0 3px 10px rgba(243,146,0,.32); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { color: var(--text); background: var(--surface-2); }
.btn.small { height: 28px; padding: 0 10px; font-size: 12px; }
.btn.danger { color: var(--err); }
.btn:disabled { opacity: .4; cursor: not-allowed; }

/* ---------- Layout ---------- */
.layout { display: grid; grid-template-columns: var(--sb-w) 1fr; height: calc(100% - 56px - 28px); }
.sidebar { overflow-y: auto; padding: 12px; border-right: 1px solid var(--line); background: var(--bg); }
.main { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 12px; min-width: 0; min-height: 0; }
.main.single-2d { grid-template-columns: 1fr 0; }
.main.single-3d { grid-template-columns: 0 1fr; }
.pane { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden; position: relative; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.pane-head { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.pane-head .title { font-weight: 600; font-size: 13px; color: var(--text); margin-right: auto; }
.pane-body { flex: 1; position: relative; min-height: 0; }
.statusbar {
  height: 28px; display: flex; align-items: center; gap: 18px; padding: 0 16px; font-size: 11.5px; color: var(--text-2);
  background: var(--surface); border-top: 1px solid var(--line);
}
.statusbar .warn-btn { cursor: pointer; font-weight: 500; color: var(--ok); }
.statusbar .warn-btn.has-err { color: var(--err); }
.statusbar .warn-btn.has-warn { color: var(--warn); }
.statusbar .spacer { flex: 1; }

/* ---------- Segmented ---------- */
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 2px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 4px 10px; border-radius: 4px; font-size: 12px; font-weight: 500; color: var(--text-2); cursor: pointer; white-space: nowrap; }
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 0 0 1px var(--line-strong); }
[data-theme="dark"] .seg button.on, :root:not([data-theme]) .seg button.on { background: var(--line-strong); box-shadow: none; }
.seg.full { display: flex; width: 100%; flex-wrap: wrap; }   /* (21-10) se le voci non ci stanno vanno a capo: mai testo tagliato (Pietro: «Molla» tagliata nei tutori) */
.seg.full button { flex: 1; }

/* ---------- Sezioni sidebar ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; margin-bottom: 9px; position: relative; overflow: hidden;
  box-shadow: 0 1px 2px rgba(0,0,0,.05); transition: border-color .18s, box-shadow .18s, transform .18s;
}
.card:not([open]):hover { border-color: var(--line-strong); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,.07); }
.card[open] { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); box-shadow: 0 8px 22px rgba(243,146,0,.12), 0 2px 10px rgba(0,0,0,.06); }
.card[open]::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--accent); }
@keyframes cardIn { from { opacity: 0; transform: translateY(-5px); } to { opacity: 1; transform: none; } }
.card[open] > .card-body { animation: cardIn .22s cubic-bezier(.22,.61,.36,1); }
@media (prefers-reduced-motion: reduce) { .card, .card[open] > .card-body { animation: none !important; transition: none; } }
.card > summary {
  list-style: none; cursor: pointer; padding: 11px 14px; font-weight: 600; font-size: 13.5px; color: var(--text);
  display: flex; align-items: center; gap: 11px; transition: background-color .15s;
}
.card[open] > summary { color: var(--accent); }
.card:not([open]) > summary:hover { background: var(--surface-2); }
.card > summary::-webkit-details-marker { display: none; }
.card > summary::after { content: ""; margin-left: auto; width: 6px; height: 6px; border-right: 1.5px solid var(--text-3); border-bottom: 1.5px solid var(--text-3); transform: rotate(45deg) translateY(-2px); }
.card:not([open]) > summary::after { transform: rotate(-45deg); }
.card-body { padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.card-next { margin-top: 2px; padding-top: 12px; border-top: 1px solid var(--line); }
.card-next .btn { width: 100%; height: 38px; font-size: 13px; }
/* gruppo di azioni affiancate: riempiono la riga, vanno a capo in modo pulito (non impilate e disallineate) */
.actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(92px, 1fr)); gap: 8px; }
.actions > .btn { width: 100%; min-width: 0; height: 34px; }
.row { display: flex; flex-direction: column; gap: 6px; }
.row-h { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.lbl { font-size: 12px; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.lbl .tip {
  width: 14px; height: 14px; border-radius: 50%; border: 1px solid var(--line-strong); color: var(--text-3); font-size: 9px;
  display: inline-flex; align-items: center; justify-content: center; cursor: help; flex: none;
}
.val { display: flex; align-items: center; gap: 4px; }
.val input[type=number] { width: 60px; height: 26px; border: 1px solid var(--line-strong); border-radius: 5px; padding: 0 6px; text-align: right; font-size: 12px; background: var(--field); }
.val input[type=number]:focus, input.txt:focus, select.sel:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.val .unit { font-size: 11px; color: var(--text-3); min-width: 16px; }

/* cursori */
input[type=range] {
  --th: 24px; --tk: 8px; --z: 0; --f: 0;
  --zx: calc(var(--th) / 2 + (100% - var(--th)) * var(--z)); --fx: calc(var(--th) / 2 + (100% - var(--th)) * var(--f));
  -webkit-appearance: none; appearance: none; width: 100%; min-width: 0; max-width: 100%; height: 30px; margin: 0; background: transparent; cursor: pointer;
}
/* binario spesso: riempimento dallo zero (o dall'inizio) fino alla levetta, tacca sullo zero se il cursore va nei due versi */
input[type=range]::-webkit-slider-runnable-track {
  height: var(--tk); border-radius: var(--tk);
  background:
    linear-gradient(to right, transparent calc(var(--zx) - 1.5px), var(--text-2) calc(var(--zx) - 1.5px), var(--text-2) calc(var(--zx) + 1.5px), transparent calc(var(--zx) + 1.5px)),
    linear-gradient(to right, transparent min(var(--zx), var(--fx)), var(--accent) min(var(--zx), var(--fx)), var(--accent) max(var(--zx), var(--fx)), transparent max(var(--zx), var(--fx))),
    var(--line-strong);
}
input[type=range]:not(.bipolar)::-webkit-slider-runnable-track { background: linear-gradient(to right, var(--accent) var(--fx), var(--line-strong) var(--fx)); }
input[type=range]::-moz-range-track { height: var(--tk); border-radius: var(--tk); background: var(--line-strong); }
input[type=range].bipolar::-moz-range-track { background: linear-gradient(to right, transparent calc(var(--zx) - 1.5px), var(--text-2) calc(var(--zx) - 1.5px), var(--text-2) calc(var(--zx) + 1.5px), transparent calc(var(--zx) + 1.5px)), linear-gradient(to right, transparent min(var(--zx), var(--fx)), var(--accent) min(var(--zx), var(--fx)), var(--accent) max(var(--zx), var(--fx)), transparent max(var(--zx), var(--fx))), var(--line-strong); }
input[type=range]:not(.bipolar)::-moz-range-progress { height: var(--tk); border-radius: var(--tk); background: var(--accent); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: var(--th); height: var(--th); border-radius: 50%; margin-top: calc((var(--tk) - var(--th)) / 2); background: #fff; border: 3px solid var(--accent); box-shadow: 0 1px 4px rgba(0,0,0,.35); }
input[type=range]::-moz-range-thumb { width: calc(var(--th) - 6px); height: calc(var(--th) - 6px); border-radius: 50%; background: #fff; border: 3px solid var(--accent); box-shadow: 0 1px 4px rgba(0,0,0,.35); }

select.sel, input.txt { height: 30px; border: 1px solid var(--line-strong); border-radius: 6px; padding: 0 8px; font-size: 13px; background: var(--field); width: 100%; color: var(--text); }
select.sel option { background: var(--surface); color: var(--text); }
input[type=color] { width: 100%; height: 30px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--field); padding: 2px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; color: var(--text); }
.check input { accent-color: var(--accent); width: 15px; height: 15px; }
.pane-head .check { font-size: 12px; color: var(--text-2); }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 14px; }
.cl-list { display: flex; flex-direction: column; gap: 4px; max-height: 50vh; overflow-y: auto; margin: 10px 0; }
.cl-row { display: flex; align-items: center; gap: 10px; text-align: left; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: none; color: var(--text); cursor: pointer; font: inherit; }
.cl-row:hover { border-color: var(--accent); }
.cl-row small, .client-box small { display: block; color: var(--text-3); font-size: 11.5px; margin-top: 2px; }
.cf-prev { margin-top: 12px; padding: 10px; border: 1px dashed var(--line-strong); border-radius: 6px; display: flex; flex-direction: column; gap: 4px; }
.cf-prev:empty { display: none; }   /* anteprima del plantare: niente cornice vuota */
.client-box { display: flex; flex-direction: column; gap: 6px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; }
.client-box .btn { align-self: flex-start; }
.grid2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px 14px; }
.grid2 > *, .row, .row-h { min-width: 0; }
.row-h .lbl { min-width: 0; }
/* (21-10, Pietro: «errore nel tab della molla, occhio che non sia anche altrove») etichetta + valore: se non ci stanno sulla
   stessa riga il valore va sotto, a destra. Prima l'etichetta si stringeva sotto la casella del numero e il «?» spariva
   (sedute: Larghezza, Profondità, Inclinazione…; plantari: Largh. avampiede; editor della scansione: Avanti/indietro) */
.row-h { flex-wrap: wrap; }
.row-h > .lbl { min-width: min-content; }
.row-h > .val { margin-left: auto; }
.grid2 .val input[type=number] { width: 52px; }
.hint { font-size: 11.5px; color: var(--text-2); line-height: 1.5; }
.hint b { color: var(--text); font-weight: 600; }
.stat { display: flex; gap: 6px; flex-wrap: wrap; }
.pill { font-size: 11px; padding: 2px 8px; border-radius: 4px; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--line); }
.pill.ok { color: var(--ok); }
.pill.warn { color: var(--warn); }
.pill.err { color: var(--err); }
.divider { height: 1px; background: var(--line); margin: 2px 0; }
.lock-btn { border: 1px solid var(--line-strong); background: var(--field); border-radius: 5px; width: 28px; height: 26px; cursor: pointer; font-size: 12px; }
.lock-btn.on { border-color: var(--accent); background: var(--accent-soft); }

/* Zone / inserti */
.zone-item { border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; display: flex; flex-direction: column; gap: 8px; cursor: pointer; }
.zone-item.sel { border-color: var(--accent); }
.zone-item .zhead { display: flex; align-items: center; gap: 8px; }
.zone-item .zhead input { flex: 1; border: 0; border-bottom: 1px dashed var(--line-strong); background: transparent; font-weight: 500; font-size: 13px; padding: 2px 0; min-width: 0; color: var(--text); }
.swatch { width: 10px; height: 10px; border-radius: 2px; flex: none; }
.zone-item .zdel { border: 0; background: none; color: var(--text-3); cursor: pointer; font-size: 15px; }
.zone-item .zdel:hover { color: var(--err); }

/* ---------- Vista 2D ---------- */
svg.plan {
  width: 100%; height: 100%; display: block; cursor: grab; touch-action: none;
  background: linear-gradient(90deg, var(--plan-grid) 1px, transparent 1px) 0 0 / 24px 24px, linear-gradient(var(--plan-grid) 1px, transparent 1px) 0 0 / 24px 24px, var(--plan-bg);
}
svg.plan.panning { cursor: grabbing; }
svg.plan, svg.plan * { -webkit-user-select: none; user-select: none; }
svg.plan .edge-hit { fill: none; stroke: transparent; stroke-width: 14px; pointer-events: stroke; cursor: move; }   /* clic = sposta, doppio clic = nuovo punto */
svg.plan .edge-hit:hover { stroke: var(--accent); stroke-opacity: .25; }
svg.plan .hit:active { cursor: grabbing; }
svg.plan .outline-top { fill: none; stroke: var(--plan-line); stroke-width: 2; }
svg.plan .base-fill { fill: var(--accent-soft); stroke: none; }
svg.plan .seg-ok { stroke: var(--ok); }
svg.plan .seg-warn { stroke: var(--warn); }
svg.plan .seg-err { stroke: var(--err); }
svg.plan .cp { fill: var(--cp-fill); stroke: var(--accent); stroke-width: 2.5; cursor: pointer; }
svg.plan .cp.mod { fill: var(--accent); }
svg.plan .cp:hover, svg.plan .cp.drag { fill: var(--accent-hover); }
svg.plan .cp-link { stroke: var(--accent); stroke-opacity: .5; stroke-dasharray: 3 3; }
svg.plan .zone { stroke-width: 1.5; cursor: move; }
svg.plan .zone.sel { stroke-width: 3; }
svg.plan .zcp { fill: var(--cp-fill); stroke-width: 2.5; cursor: pointer; }
svg.plan .zcp.on { fill: var(--accent); stroke-width: 3; }   /* punto selezionato: Canc lo toglie */
svg.plan .engr { fill: var(--engr); fill-rule: evenodd; cursor: move; }
svg.plan .engr.sel { fill: var(--accent); }
svg.plan .rot-handle { fill: var(--cp-fill); stroke: var(--accent); stroke-width: 2.5; cursor: grab; }
svg.plan .rot-line { stroke: var(--accent); stroke-opacity: .5; }
svg.plan .axis { stroke: var(--plan-dim); stroke-dasharray: 6 5; }
svg.plan .dim-line { fill: none; stroke: var(--plan-dim); stroke-dasharray: 3 3; }
svg.plan .base-inner { fill: var(--plan-base); stroke: var(--plan-line); stroke-width: 1.5; }
svg.plan .ruler { stroke: var(--plan-dim); stroke-width: 1; }
svg.plan .lbl2d { font-size: 10.5px; fill: var(--text-2); text-anchor: middle; dominant-baseline: middle; pointer-events: none; paint-order: stroke; stroke: var(--plan-bg); stroke-width: 3px; font-variant-numeric: tabular-nums; }
svg.plan .lbl2d.strong { fill: var(--text); font-weight: 600; }
svg.plan .lbl2d.el-t { font-size: 11px; fill: var(--text); }
svg.plan .lbl2d.lm-t { fill: var(--text-3); font-size: 10px; }
svg.plan .lm-line { fill: none; stroke: var(--text-3); stroke-dasharray: 4 3; stroke-opacity: .8; }
svg.plan .lm-dot { fill: var(--text-3); }
svg.plan .del { fill: var(--accent); fill-opacity: .22; stroke: var(--accent); stroke-width: 1.5; cursor: move; }
svg.plan .del.neg { fill: var(--relief); stroke: var(--relief); }
svg.plan .del.sel { fill-opacity: .4; stroke-width: 2.5; }
svg.plan .del.off { fill-opacity: .05; stroke-dasharray: 4 3; }
.range-ends { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-top: -6px; font-size: 10.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.range-ends b { font-weight: 500; color: var(--text-2); text-align: center; }
.bipolar { position: relative; }
.hint.on { color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--text); border-radius: 999px; padding: 5px 10px; font: inherit; font-size: 12px; cursor: pointer; }
.chip:hover { border-color: var(--accent); }
.chip.on { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
/* titolo di gruppo senza riga sotto: la riga arancione spuntava dagli angoli arrotondati della scheda (puntini) */
.sb-group { display: flex; align-items: center; gap: 8px; margin: 4px 2px 0; padding: 4px 0 4px; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--accent); }
.sb-group .bi { display: inline-flex; }
.sb-group .bi svg { width: 14px; height: 14px; }
.sb-group.print { margin-top: 14px; color: var(--text-2); }
svg.plan .sec-line { stroke: var(--relief); stroke-width: 1.5; stroke-dasharray: 6 4; }
svg.plan .sec-handle { fill: var(--relief); stroke: #fff; stroke-width: 1.5; pointer-events: none; }
svg.plan .sec-hit { cursor: ns-resize; }
svg.plan .lbl2d.sec-t { fill: var(--relief); }
svg.plan .q-dot { fill: var(--text); }
svg.plan .lbl2d.q-t { font-size: 10px; fill: var(--text); transform-box: fill-box; dominant-baseline: text-after-edge; }
.sec-graph { width: 100%; height: 150px; display: block; background: var(--plan-bg); border: 1px solid var(--line); border-radius: 6px; }
.sec-graph .top { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 1.5; }
.sec-graph .grid { stroke: var(--line); stroke-width: 1; }
.sec-graph text { font-size: 10px; fill: var(--text-2); font-variant-numeric: tabular-nums; }
.sec-graph text.v { fill: var(--text); font-weight: 600; }
.fix-row { display: grid; grid-template-columns: 1fr auto auto auto; gap: 6px; align-items: center; font-size: 12.5px; }
.fix-row input { width: 62px; }
#dlgModal.wide .modal { width: min(920px, 96vw) !important; }
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin: 12px 0; max-height: 62vh; overflow-y: auto; padding: 2px; }
.lib-card { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; cursor: pointer; text-align: center; }
.lib-card:hover { border-color: var(--accent); background: var(--accent-soft); }
.lib-card b { font-size: 12.5px; font-weight: 600; }
.lib-card small { font-size: 11px; color: var(--text-3); line-height: 1.3; }
.lib-thumb { width: 96px; height: 106px; }
.lib-thumb .th-sole { fill: var(--surface-2); stroke: var(--line-strong); stroke-width: 1; }
.lib-del { position: absolute; top: 4px; right: 6px; color: var(--text-3); font-size: 13px; }
.lib-del:hover { color: var(--err); }
.seg.grid-2 { display: grid; grid-template-columns: 1fr 1fr; }
.check.prop { align-items: flex-start; }
.check.prop span { display: flex; flex-direction: column; gap: 2px; }
.check.prop small { color: var(--text-3); font-size: 11px; line-height: 1.35; }
svg.plan .core-cp { fill: var(--text); stroke: var(--plan-bg); stroke-width: 2.5; pointer-events: none; }
svg.plan .core-cp.on { fill: var(--accent); }
svg.plan .shape-body { cursor: move; }
.sp-wrap { position: fixed; inset: 0; z-index: 200; display: grid; grid-template-columns: 340px 1fr; background: var(--bg); }
.sp-panel { display: flex; flex-direction: column; border-right: 1px solid var(--line); background: var(--surface); min-height: 0; }
.sp-head { padding: 14px 16px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 2px; }
.sp-head small { color: var(--text-3); font-size: 11.5px; }
.sp-body { flex: 1; overflow-y: auto; padding: 12px 14px; display: flex; flex-direction: column; gap: 14px; }
.sp-sec { display: flex; flex-direction: column; gap: 8px; }
.sp-note { font-size: 12px; background: var(--accent-soft); border: 1px solid var(--accent); border-radius: 6px; padding: 8px 10px; }
.sp-foot { padding: 12px 14px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.sp-view { position: relative; min-width: 0; min-height: 0; }
.sp-view canvas { display: block; width: 100%; height: 100%; }
.sp-tip { position: absolute; top: 12px; left: 12px; right: 12px; background: var(--legend-bg); border: 1px solid var(--line); border-radius: 6px; padding: 8px 12px; font-size: 12.5px; }
.sp-cams { position: absolute; bottom: 12px; right: 12px; display: flex; gap: 6px; }
.sp-stat { position: absolute; bottom: 12px; left: 12px; background: var(--legend-bg); border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; font-size: 12px; color: var(--text-2); font-variant-numeric: tabular-nums; }
@media (max-width: 760px) { .sp-wrap { grid-template-columns: 1fr; grid-template-rows: 55% 45%; } .sp-panel { order: 2; } }
.sub-h { font-size: 12px; font-weight: 600; color: var(--text-2); }
svg.plan .zone-ghost { fill: none; stroke: var(--plan-zone); stroke-dasharray: 2 3; }
svg.plan .base-ghost { fill: none; stroke: var(--accent); stroke-opacity: .6; stroke-dasharray: 4 3; }
.plan-legend {
  position: absolute; left: 10px; bottom: 10px; background: var(--legend-bg); border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px;
  font-size: 11px; color: var(--text-2); display: flex; gap: 12px; align-items: center; pointer-events: none; flex-wrap: wrap; max-width: calc(100% - 20px);
}
.plan-legend b { color: var(--text); }
.plan-legend i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; margin-right: 5px; vertical-align: middle; }
.tooltip { position: absolute; pointer-events: none; background: var(--tip-bg); color: #fff; font-size: 11px; padding: 4px 8px; border-radius: 5px; white-space: nowrap; transform: translate(12px, -30px); display: none; z-index: 3; }
.pane-tools { position: absolute; right: 10px; top: 10px; display: flex; gap: 4px; z-index: 2; }
.icon-btn { width: 28px; height: 28px; border-radius: 6px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-size: 13px; color: var(--text-2); display: inline-flex; align-items: center; justify-content: center; padding: 0; }
/* barra dei punti di vista (colonna in alto a destra nel riquadro 3D) — comune a tutti i moduli */
.view-bar { position: absolute; top: 10px; right: 10px; z-index: 3; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.view-bar .seg { background: var(--legend-bg); flex-wrap: wrap; justify-content: flex-end; }
.icon-btn:hover { color: var(--text); border-color: var(--line-strong); }

/* Scala colori (mappa) */
.colorbar { position: absolute; right: 10px; bottom: 10px; background: var(--legend-bg); border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; font-size: 11px; color: var(--text-2); display: none; align-items: center; gap: 8px; z-index: 2; }
.colorbar.on { display: flex; }
.colorbar .ramp { width: 140px; height: 8px; border-radius: 2px; background: linear-gradient(90deg, #2B5CD6, #22B8CF, #3DBE5C, #F2D22E, #F39200, #E0302A); }

/* ---------- Vista 3D ---------- */
#view3d { position: absolute; inset: 0; }
#view3d canvas { display: block; }

/* ---------- Schermata iniziale ---------- */
.empty { position: absolute; inset: 56px 0 28px 0; display: flex; align-items: center; justify-content: center; color: var(--text-2); text-align: center; padding: 20px; z-index: 4; background: var(--bg); }

/* ---------- Modale ---------- */
.modal-back { position: fixed; inset: 0; background: var(--overlay); display: none; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.modal-back.open { display: flex; }
.modal { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; width: min(720px, 100%); max-height: 90vh; display: flex; flex-direction: column; box-shadow: 0 16px 48px rgba(0,0,0,.25); }
.modal header { display: flex; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); gap: 10px; }
.modal header h3 { margin: 0; font-size: 15px; font-weight: 600; flex: 1; }
.modal header img { height: 18px; }
.modal .body { padding: 16px 18px; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; }
.modal .tabs { display: flex; gap: 2px; padding: 8px 18px 0; border-bottom: 1px solid var(--line); }
.modal .tabs button { border: 0; background: none; padding: 8px 12px; font-weight: 500; font-size: 13px; color: var(--text-2); cursor: pointer; border-bottom: 2px solid transparent; }
.modal .tabs button:hover { color: var(--text); }
.modal .tabs button.on { color: var(--text); border-color: var(--accent); }
.modal footer { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; }
/* Impostazioni: altezza FISSA così la finestra non cambia dimensione cambiando scheda; il contenuto scorre dentro. */
#settingsModal .modal { height: min(680px, 90vh); }
#settingsModal .body { flex: 1 1 auto; min-height: 0; }
.logo-preview { border: 1px dashed var(--line-strong); border-radius: 8px; height: 110px; display: flex; align-items: center; justify-content: center; background: #F7F8FA; overflow: hidden; }
.logo-preview svg, .logo-preview img { max-width: 90%; max-height: 90px; }
.logo-preview .hint { color: #5F6670; }
.preset-list { display: flex; flex-direction: column; gap: 6px; }
.preset-row { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; }
.preset-row b { flex: 1; font-size: 13px; font-weight: 500; }
.section-title { font-size: 12px; font-weight: 600; color: var(--text); }
.about { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; padding: 8px 0; }
.about .card-light { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 18px 24px; width: 100%; display: flex; justify-content: center; }
.about .card-light img { max-width: 100%; height: 64px; object-fit: contain; }

.warn-list { position: fixed; bottom: 34px; left: 12px; width: min(520px, calc(100% - 24px)); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 12px 36px rgba(0,0,0,.25); padding: 8px 12px; display: none; z-index: 30; max-height: 50vh; overflow-y: auto; }
.warn-list.open { display: block; }
.warn-list div { font-size: 12.5px; padding: 7px 4px; border-bottom: 1px solid var(--line); display: flex; gap: 8px; }
.warn-list div:last-child { border: 0; }

.toast { position: fixed; right: 16px; bottom: 40px; display: flex; align-items: center; gap: 8px; background: var(--tip-bg); color: #fff; padding: 10px 14px; border-radius: 8px; font-size: 13px; box-shadow: 0 8px 24px rgba(0,0,0,.25); opacity: 0; transform: translateY(6px); transition: .2s; z-index: 60; pointer-events: none; max-width: 420px; }
.toast.show { opacity: 1; transform: none; }
.busy { position: absolute; right: 12px; bottom: 12px; font-size: 11px; color: var(--text-2); background: var(--legend-bg); border: 1px solid var(--line); padding: 3px 9px; border-radius: 5px; display: none; }
.busy.on { display: flex; align-items: center; gap: 6px; }
.busy.on::before { content: ""; width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid var(--line-strong); border-top-color: var(--accent); animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 1100px) {
  :root { --sb-w: 320px; }
  .main { grid-template-columns: 1fr; grid-template-rows: 1fr 1fr; }
  .main.single-2d, .main.single-3d { grid-template-columns: 1fr; }
}
/* ---------- Menu File e nome progetto ---------- */
.menu-wrap { position: relative; }
.menu {
  position: absolute; top: calc(100% + 6px); left: 0; min-width: 250px; background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: 8px; box-shadow: 0 12px 32px rgba(0,0,0,.28); padding: 5px; display: none; z-index: 40;
}
.menu-wrap.open > .menu { display: block; }
.menu-item {
  display: grid; grid-template-columns: 20px 1fr auto; align-items: center; justify-content: space-between; gap: 10px; width: 100%; padding: 7px 10px; border: 0; background: none;
  border-radius: 5px; font-size: 13px; color: var(--text); cursor: pointer; text-align: left;
}
.menu-item:hover { background: var(--surface-2); }
.menu-item kbd { font-family: inherit; font-size: 11px; color: var(--text-3); }
.menu-item small { font-size: 11px; color: var(--text-3); }
.menu-item.recent span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-sep { height: 1px; background: var(--line); margin: 5px 4px; }
.menu-label { font-size: 11px; color: var(--text-3); padding: 6px 10px 2px; }
.menu-empty { font-size: 12px; color: var(--text-3); padding: 4px 10px 6px; }
.prj-name { font-size: 13px; font-weight: 500; color: var(--text); max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: default; }
.prj-name.dirty::after { content: " ●"; color: var(--accent); }

/* ---------- Icone di sezione, piede attivo, differenze DX/SX ---------- */
.sec-icon {
  display: inline-flex; width: 28px; height: 28px; border-radius: 8px; align-items: center; justify-content: center; flex: none;
  background: var(--surface-2); color: var(--text-2); transition: background-color .15s, color .15s;
}
.card[open] > summary .sec-icon { background: var(--accent-soft); color: var(--accent); }
.card:not([open]) > summary:hover .sec-icon { color: var(--text); }
.card > summary:hover .sec-icon { color: var(--accent-hover); }
.edit-wrap { display: flex; align-items: center; gap: 4px; }
.edit-wrap .seg button { padding: 4px 9px; }
.diff-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--accent); border: 0; padding: 0; margin-left: 2px; cursor: pointer; flex: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.diff-dot:hover { transform: scale(1.3); }
.seg-diff { display: flex; justify-content: flex-end; margin-bottom: -8px; }

/* aree di presa dei punti (più grandi del punto visibile) */
svg.plan .hit { fill: transparent; stroke: none; cursor: grab; }
svg.plan .hit + .cp, svg.plan .hit + .zcp, svg.plan .hit + .core-cp { pointer-events: none; }
svg.plan .hit:hover + .cp { fill: var(--accent); stroke-width: 3; }
svg.plan .hit:hover + .zcp { stroke-width: 3; }

/* ---------- Barra dei menu ---------- */
.menubar { display: flex; align-items: center; gap: 2px; }
.mb-btn { border: 0; background: none; color: var(--text-2); font-size: 13px; padding: 6px 10px; border-radius: 6px; cursor: pointer; }
.mb-btn:hover, .menu-wrap.open .mb-btn { background: var(--surface-2); color: var(--text); }
.menu-item .mi-ico { display: inline-flex; color: var(--text-2); }
.menu-item:disabled { opacity: .4; cursor: default; }
.menu-item:disabled:hover { background: none; }
.menu-item .mi-check { color: var(--accent); }
.menu-item .caret-r { display: inline-flex; color: var(--text-3); font-size: 11px; }
.submenu-wrap { position: relative; }
.submenu-wrap > .menu { top: -6px; left: calc(100% + 2px); display: none; }
.submenu-wrap:hover > .menu-item:not(:disabled) + .menu { display: block; }
.menu-item span { white-space: nowrap; }
.btn .bi { display: inline-flex; }
#btnExport { gap: 7px; }

/* ---------- Home ---------- */
.home { width: 100%; max-width: 640px; display: flex; flex-direction: column; gap: 34px; text-align: left; }
.home-sec { display: flex; flex-direction: column; gap: 12px; }
.home h1 { margin: 0; font-size: 13px; font-weight: 600; color: var(--text-2); text-transform: none; letter-spacing: 0; }
.home-open {
  display: flex; align-items: center; gap: 14px; width: 100%; padding: 14px 16px; border: 1px solid var(--line-strong); border-radius: 10px;
  background: var(--surface); color: var(--text); cursor: pointer; text-align: left; font: inherit;
}
.home-open:hover { border-color: var(--accent); }
.home-open .ico { color: var(--accent); display: inline-flex; }
.home-open b, .new-card b { display: block; font-size: 14px; font-weight: 600; }
.home-open small, .new-card small { display: block; font-size: 12px; color: var(--text-2); margin-top: 2px; }
.recent-list { display: flex; flex-direction: column; }
.recent-list:empty { display: none; }
.recent-item {
  display: grid; grid-template-columns: 22px 1fr auto; align-items: center; gap: 12px; padding: 9px 12px; border: 0; border-radius: 8px;
  background: none; color: var(--text); cursor: pointer; text-align: left; font: inherit; font-size: 13px;
}
.recent-item:hover { background: var(--surface-2); }
.recent-item .ri-ico { color: var(--text-2); display: inline-flex; }
.recent-item small { color: var(--text-3); font-size: 11.5px; }
/* lista progetti cloud: nome in evidenza (una riga), data·email piccola sotto — non più nome strizzato ed email gigante */
.recent-item.ri-stack { grid-template-columns: 22px 1fr; align-items: center; }
.recent-item.ri-stack .ri-txt { display: flex; flex-direction: column; min-width: 0; gap: 1px; }
.recent-item.ri-stack .ri-name { font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-item.ri-stack small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.new-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.new-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 10px; padding: 20px; border: 1px solid var(--line-strong); border-radius: 10px;
  background: var(--surface); color: var(--text); cursor: pointer; text-align: left; font: inherit;
}
.new-card:hover { border-color: var(--accent); background: var(--accent-soft); }
.new-card .ico-big { color: var(--accent); display: inline-flex; }
.home.wide { max-width: 860px; }
.home.narrow { max-width: 380px; }
.login-card { display: flex; flex-direction: column; gap: 14px; padding: 28px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.login-card h2 { margin: 0; font-size: 18px; font-weight: 600; }
.login-card form { display: flex; flex-direction: column; gap: 12px; }
.login-card .btn.primary { justify-content: center; height: 38px; }
.login-card .link-btn { align-self: flex-start; }
/* conferma ben visibile: email / codice inviati (17-10) */
.sent-ok { display: flex; align-items: center; gap: 12px; }
.sent-ico { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 50%; background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); flex: none; }
.sent-ico svg { stroke: currentColor; }
.sent-txt { margin: 0; line-height: 1.5; }
.code-in { font-size: 22px; letter-spacing: .3em; text-align: center; font-variant-numeric: tabular-nums; }
.login-card .hint .link-btn { font-size: inherit; }
.login-logo { height: 30px; align-self: flex-start; }
[data-theme="light"] .login-logo { content: url(../img/formaxis-light.png); }
body[data-auth="out"] #menubar, body[data-auth="out"] #statCloud { visibility: hidden; }
.home-grid3 { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 14px; }
.home-grid3 .new-card { min-height: 170px; }
.new-card:disabled { opacity: .4; cursor: default; }
.new-card:disabled:hover { border-color: var(--line); background: var(--surface); }
.new-card .soon { font-size: 11px; color: var(--text-3); margin-top: 6px; }
.home-head { display: flex; align-items: center; gap: 10px; }
.home-head h2 { margin: 0; font-size: 17px; font-weight: 600; }
.home-head .icon-btn { width: 34px; height: 34px; }
.home-sec h1 .bi { vertical-align: -3px; margin-right: 4px; }
.client-card { display: flex; flex-direction: column; gap: 10px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 8px; }
.client-card small { color: var(--text-2); }

/* ---------- Importazione nel modulo ---------- */
.import-panel { width: 100%; max-width: 520px; display: flex; flex-direction: column; align-items: center; gap: 16px; }
.import-panel[hidden], .home[hidden] { display: none; }
.import-panel .seg button { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; }
.import-panel .seg button:disabled { opacity: .4; cursor: not-allowed; }
.drop-area {
  width: 100%; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 40px 24px; border: 1.5px dashed var(--line-strong);
  border-radius: 12px; background: var(--surface); text-align: center;
}
.drop-area .ico-big { color: var(--accent); display: inline-flex; margin-bottom: 4px; }
.drop-area b { font-size: 15px; font-weight: 600; }
.drop-area small { font-size: 12.5px; color: var(--text-2); margin-bottom: 8px; }
.drop-area.over { border-color: var(--accent); background: var(--accent-soft); }
.link-btn { border: 0; background: none; color: var(--text-2); font-size: 12.5px; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.link-btn:hover { color: var(--text); }


.shortcut-list { display: grid; gap: 6px; }
.shortcut-list div { display: grid; grid-template-columns: 170px 1fr; gap: 12px; align-items: center; font-size: 13px; }
.shortcut-list kbd { font-family: inherit; font-size: 12px; background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: 5px; padding: 2px 7px; justify-self: start; }

/* ---------- Cloud ---------- */
.bi { display: inline-flex; vertical-align: middle; }
.stat-cloud { display: inline-flex; align-items: center; gap: 5px; }
.prj-name .bi { margin-right: 4px; color: var(--text-3); }   /* nuvoletta = icona messa da updateTitle (niente carattere ☁) */
.search-box { display: flex; align-items: center; gap: 8px; color: var(--text-3); }
.recent-row { display: flex; align-items: center; gap: 4px; }
.recent-row .recent-item { flex: 1; }
#dlgFoot:empty { display: none; }

/* ---------- Telefono ---------- */
.mobile-tabs { display: none; }
@media (max-width: 760px) {
  html, body { overflow: hidden; height: 100%; }
  body { height: 100dvh; }
  .topbar { height: 52px; flex-wrap: nowrap; padding: 0 10px; gap: 6px; }
  .brand img { height: 18px; }
  .menubar { order: -1; }
  .menubar .mb-btn { padding: 8px; display: inline-flex; color: var(--text); }
  .menu { position: fixed; left: 8px; right: 8px; top: 52px; max-height: calc(100dvh - 70px); overflow-y: auto; min-width: 0; }
  .submenu-wrap > .menu { position: static; display: none; box-shadow: none; border: 0; padding: 0 0 0 22px; max-height: none; }
  .submenu-wrap:hover > .menu-item:not(:disabled) + .menu { display: none; }
  .submenu-wrap.open > .menu { display: block; }
  .menu-item { padding: 11px 10px; font-size: 15px; }
  .menu-item kbd { display: none; }
  .prj-name { max-width: 34vw; font-size: 13px; }
  .steps { flex: 1; justify-content: flex-end; overflow-x: auto; min-width: 0; }
  .foot-tab { padding: 4px; font-size: 0; gap: 0; }
  body[data-screen="work"] .brand { display: none; }
  .foot-tab .x { display: none; }
  .edit-wrap { display: none !important; }
  #btnExport { padding: 0 10px; }
  #btnExport .bl { display: none; }

  .layout { display: block; height: calc(100dvh - 52px - 58px); }
  .sidebar { display: none; height: 100%; border: 0; padding: 10px; }
  .main { display: block; height: 100%; padding: 8px; }
  .main > .pane { display: none; height: 100%; }
  body[data-mtab="params"] .sidebar { display: block; }
  body[data-mtab="params"] .main { display: none; }
  body[data-mtab="plan"] #pane2d, body[data-mtab="3d"] #pane3d { display: flex; }
  .statusbar { display: none; }
  .mobile-tabs {
    position: fixed; left: 0; right: 0; bottom: 0; height: 58px; display: flex; background: var(--surface); border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom); z-index: 20;
  }
  body[data-screen="home"] .mobile-tabs, body[data-screen="import"] .mobile-tabs { display: none; }
  .mobile-tabs button { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; border: 0; background: none; color: var(--text-3); font-size: 11px; }
  .mobile-tabs button.on { color: var(--accent); }
  .pane-head { padding: 6px 8px; }
  .pane-head .seg button { padding: 5px 8px; }
  .plan-legend { display: none; }

  .empty { position: fixed; inset: 52px 0 0 0; align-items: flex-start; overflow-y: auto; padding: 22px 16px 40px; }
  .home { gap: 26px; }
  .new-grid, .home-grid3 { grid-template-columns: 1fr; grid-auto-flow: row; }
  .home-grid3 .new-card { min-height: 0; }
  .new-card { flex-direction: row; align-items: center; padding: 14px 16px; gap: 14px; }
  .drop-area { padding: 28px 16px; }

  input.txt, select.sel, .val input[type=number], input[type=color] { font-size: 16px; }
  .val input[type=number] { width: 70px; height: 32px; }
  input[type=range] { --th: 32px; --tk: 10px; height: 38px; }
  .card > summary { padding: 14px; font-size: 14px; }
  .btn.small { height: 34px; }
  .grid2 { grid-template-columns: 1fr; }
  .grid3 { grid-template-columns: 1fr 1fr; }
  .modal-back { padding: 0; align-items: stretch; }
  .modal { width: 100% !important; max-height: 100dvh; border-radius: 0; }
  .toast { left: 12px; right: 12px; bottom: 70px; max-width: none; }
  .warn-list { bottom: 70px; }
}

/* ---------- Telefono in orizzontale: parametri a sinistra + una vista (Pianta o 3D) a destra ---------- */
@media (orientation: landscape) and (max-height: 520px) {
  html, body { overflow: hidden; height: 100%; }
  body { height: 100dvh; }
  .topbar { height: 46px; flex-wrap: nowrap; }
  .statusbar { display: none; }
  body[data-mtab] .layout { display: grid; grid-template-columns: minmax(250px, 40%) 1fr; height: calc(100dvh - 46px); }
  body[data-mtab] .sidebar { display: block; height: 100%; overflow-y: auto; padding: 8px; border-right: 1px solid var(--line); }
  body[data-mtab] .main { display: block; height: 100%; padding: 6px 6px 48px; }
  body[data-mtab] .main > .pane { display: none; height: 100%; }
  body[data-mtab="plan"] #pane2d, body[data-mtab="3d"] #pane3d, body[data-mtab="params"] #pane3d { display: flex; }
  /* selettore Pianta / 3D sotto la vista (Parametri è sempre visibile) */
  .mobile-tabs {
    position: fixed; left: auto; right: 0; bottom: 0; width: 60%; height: 42px; display: flex; background: var(--surface);
    border-top: 1px solid var(--line); border-left: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); z-index: 20;
  }
  .mobile-tabs button { flex: 1; display: flex; flex-direction: row; align-items: center; justify-content: center; gap: 6px; border: 0; background: none; color: var(--text-3); font-size: 13px; }
  .mobile-tabs button.on { color: var(--accent); }
  .mobile-tabs button[data-mtab="params"] { display: none; }
  body[data-screen="home"] .mobile-tabs, body[data-screen="import"] .mobile-tabs { display: none; }
  .plan-legend { display: none; }
  .pane-head { padding: 4px 8px; }
  .grid2 { grid-template-columns: 1fr; }
  .toast { bottom: 50px; }
}

/* ---------- Strumenti di modellatura 3D (barra verticale a sinistra della vista 3D) ---------- */
.tool-rail { position: absolute; left: 10px; top: 10px; z-index: 3; display: flex; flex-direction: column; gap: 4px; width: 64px; }
.tool-rail > button {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px 5px; border: 1px solid var(--line);
  border-radius: 8px; background: var(--surface); color: var(--text-2); font-size: 10px; cursor: pointer; line-height: 1.1;
}
.tool-rail > button:hover { color: var(--text); border-color: var(--line-strong); }
.tool-rail > button.on { color: var(--accent); border-color: var(--accent); background: var(--surface-2); }
.tool-rail > button:first-child span { display: none; }
.tool-rail .tool-opts {
  position: absolute; left: 72px; top: 0; width: 210px; padding: 10px; border: 1px solid var(--line-strong); border-radius: 8px;
  background: var(--surface); box-shadow: 0 8px 24px rgba(0,0,0,.25); display: flex; flex-direction: column; gap: 4px; font-size: 12px;
}
.tool-rail .tool-opts[hidden] { display: none; }
.tool-rail .tool-opts label { display: flex; justify-content: space-between; align-items: center; color: var(--text-2); }
.tool-rail .tool-opts [hidden] { display: none; }
.tool-rail .tool-opts .val input { width: 56px; }
.tool-rail .tool-hint { color: var(--text-3); font-size: 11px; line-height: 1.35; margin-top: 4px; }
@media (max-width: 760px), (orientation: landscape) and (max-height: 520px) {
  .tool-rail { width: 44px; } .tool-rail > button span { display: none; }
  .tool-rail .tool-opts { left: 50px; width: 180px; }
}

/* punti di ripristino */
.rp-row { display: flex; align-items: center; gap: 10px; cursor: default; }
.rp-row > span:nth-child(2) { display: flex; flex-direction: column; }
.rp-act { margin-left: auto; display: flex; gap: 6px; align-items: center; }

/* 3.47 — pannello semplificato: blocchi "Avanzate", dati del paziente, utilità */
details.adv { border-top: 1px dashed var(--line-strong); margin-top: 6px; padding-top: 6px; }   /* "Avanzate": regolazioni tecniche in fondo alla scheda (usato anche dal busto) */
details.adv > summary { cursor: pointer; font-size: 11.5px; font-weight: 600; color: var(--text-2); list-style: none; display: flex; align-items: center; gap: 6px; padding: 2px 0; user-select: none; }
details.adv > summary::-webkit-details-marker { display: none; }
details.adv > summary::before { content: ''; width: 6px; height: 6px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(-45deg); transition: transform .15s; margin: 0 2px; }
details.adv[open] > summary::before { transform: rotate(45deg); }
details.adv > summary:hover { color: var(--text); }
.adv-body { display: flex; flex-direction: column; gap: 10px; padding-top: 8px; }
.data-block { display: flex; flex-direction: column; gap: 8px; padding: 10px; border-radius: 10px; background: var(--surface-2); }
.row-h.start { justify-content: flex-start; gap: 6px; }
.row-h.wrap { flex-wrap: wrap; }
.sum-pill { margin-left: 6px; }
.hint.warn { color: var(--warn); }
.hint.err { color: var(--err, #E0302A); }
.lock-btn svg { display: block; }
:where(button, .seg button, summary, .chip, input[type=range]):focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Home 3.47: azioni secondarie e recenti */
.home-row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 14px; }
@media (max-width: 700px) { .home-row2 { grid-template-columns: 1fr; } }
#hmCloud:empty, #emptyRecent:empty { display: none; }
.home-sec:has(#hmCloud:empty):has(#emptyRecent:empty) { display: none; }

/* barra della selezione sulla pianta (anche al tocco) */
.selbar { position: absolute; z-index: 6; display: flex; align-items: center; gap: 2px; padding: 4px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line-strong); box-shadow: 0 6px 20px rgba(0,0,0,.35); }
.selbar button { display: inline-flex; align-items: center; justify-content: center; min-width: 34px; height: 34px; border-radius: 8px; border: 0; background: transparent; color: var(--text); font-size: 17px; cursor: pointer; }
.selbar button:hover { background: var(--surface-2); }
.selbar .sb-del { color: var(--err); }
.selbar .sb-val { min-width: 64px; text-align: center; font-size: 13px; font-weight: 600; color: var(--accent); }
.selbar .sb-sep { width: 1px; height: 22px; background: var(--line-strong); margin: 0 3px; }
@media (pointer: coarse) { .selbar button { min-width: 42px; height: 42px; } }

/* ---------- Componenti comuni a tutti i moduli ---------- */
/* griglia di strumenti con icona + etichetta */
.tool-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.tool-grid button { border: 1px solid var(--line); background: var(--surface-2); border-radius: 8px; padding: 8px 4px; font-size: 11.5px; font-weight: 500; color: var(--text); cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 4px; position: relative; }
.tool-grid button:hover { border-color: var(--accent); }
.tool-grid button svg { width: 26px; height: 26px; color: var(--accent); }
.tool-grid button .used { position: absolute; top: 4px; right: 5px; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.zone-item.off { opacity: .5; }
.btn.primary.next { width: 100%; margin-top: 6px; }

/* iPad e schermi touch: comandi più grandi */
@media (pointer: coarse) {
  input.txt, select.sel, .val input[type=number] { font-size: 16px; }   /* Safari non zooma */
  .btn.small { min-height: 36px; }
  .seg button { min-height: 34px; }
  input[type=range] { --th: 32px; --tk: 10px; height: 38px; }
  .icon-btn { width: 36px; height: 36px; }
}

/* data di nascita scritta male */
input.txt[data-date].bad { border-color: var(--err); }

/* ---------- Lotto 2 semplificazione (20-10): icone al posto del testo ---------- */
.icon-btn.on { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }   /* interruttore acceso (occhio, DX+SX) */
.icon-btn.danger { color: var(--err); }   /* cestino rosso */
.card-tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 4px; margin-left: auto; }   /* azioni secondarie in alto a destra della scheda: icona + parola, a capo se non ci stanno (20-10) */
.seg button:has(.bi) { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }   /* segmento con icona (+ parola) */
.menu-item.on .mi-ico { color: var(--accent); }   /* voce spuntata che ha anche l'icona */
.modal header h3 .bi { margin-left: 8px; color: var(--text-3); }   /* lucchetto accanto al titolo (Clienti) */
.user-dot { position: relative; cursor: default; }   /* avatar nella barra di stato con pallino verde = collegato */
.user-dot .dot { position: absolute; right: -3px; bottom: -2px; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); border: 1.5px solid var(--surface); }
.statusbar .warn-btn:not([hidden]) { display: inline-flex; align-items: center; gap: 4px; }
@media (max-width: 760px) { .steps .link-tog { display: none; } }   /* su telefono DX+SX resta nascosto come prima */
/* 20-10, Pietro: niente icone da indovinare. Interruttore fra le schede a parole («DX + SX» / «Solo DX»), acceso = tutti e due */
.steps .link-tog { align-self: center; }
.link-tog.on { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
/* «Rimanda il codice»: finito il minuto il tondo con i secondi diventa un pulsante con la parola */
.ig-again .ig-txt { display: none; }
.ig-again.ready { width: auto; border-radius: 6px; padding: 0 10px; gap: 6px; }
.ig-again.ready .ig-txt { display: inline; font-size: 12px; font-weight: 500; }

/* ---------- Lotto 3 semplificazione (20-10): infografiche al posto di tabelle e tooltip ---------- */
.ig { display: block; max-width: 100%; height: auto; }
.ig text { font-size: 10px; font-weight: 500; fill: var(--text-2); stroke: none; font-variant-numeric: tabular-nums; }
.ig text.v, .ig tspan.v { fill: var(--text); font-weight: 600; }
.ig-wrap { display: flex; flex-direction: column; }
.ig-row { display: flex; flex-direction: column; }
/* mini rampa della mappa colori (stessi colori di colormap.js) accanto a Profondità / Altezze */
.ig-ramp { display: inline-block; width: 26px; height: 8px; border-radius: 2px; flex: none; background: linear-gradient(90deg, #2B5CD6, #22B8CF, #3DBE5C, #F2D22E, #F39200, #E0302A); }
.seg button:has(.ig-ramp) { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
/* calzatura: 5 pittogrammi con la parola sotto */
.seg.ig-shoes { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); }
.seg.ig-shoes button { flex-direction: column; gap: 2px; padding: 5px 2px; font-size: 10.5px; }
/* lunghezza (sagome) e profilo degli elementi (mini-sezioni) */
.seg.ig-len .bi svg { width: 20px; height: 20px; }
.seg.ig-prof .bi svg { width: 26px; height: 18px; }
/* indice d'arco: barra cavo · normale · piatto con l'indicatore al valore */
.ig-scale { display: flex; flex-direction: column; gap: 3px; padding-top: 14px; }
.ig-scale-bar { position: relative; display: flex; height: 6px; }
.ig-scale-bar i { height: 100%; flex: none; background: var(--line-strong); }
.ig-scale-bar i:first-child { border-radius: 3px 0 0 3px; }
.ig-scale-bar i:last-of-type { border-radius: 0 3px 3px 0; flex: 1; }
.ig-scale-bar i.mid { background: var(--ok); }
.ig-scale-bar b { position: absolute; top: -3px; width: 12px; height: 12px; margin-left: -6px; border-radius: 50%; background: #fff; border: 3px solid var(--accent); box-shadow: 0 1px 3px rgba(0,0,0,.35); }
.ig-scale-bar b::after { content: attr(data-v); position: absolute; left: 50%; bottom: 11px; transform: translateX(-50%); white-space: nowrap; font-size: 10.5px; font-weight: 600; color: var(--text); }
.ig-scale-l { display: flex; font-size: 10px; color: var(--text-3); }
.ig-scale-l span { text-align: center; flex: none; }
.ig-scale-l span:last-child { flex: 1; }
/* pallini colorati con il numero accanto (tallone, teste metatarsali) */
.ig-dots { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 11px; color: var(--text-2); }
.ig-dot { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.ig-dot i { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.ig-dot b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
/* fasce sotto il binario di un cursore (coppa: bassa · standard · profonda), allineate alla corsa della levetta */
.ig-bands { margin: -10px 12px 0; pointer-events: none; }
.ig-bands-bar { display: flex; height: 3px; border-radius: 2px; overflow: hidden; }
.ig-bands-bar i { height: 100%; flex: none; }
.ig-bands-bar .lo { background: var(--relief); }
.ig-bands-bar .std { background: var(--ok); }
.ig-bands-bar .hi { background: var(--accent); }
.ig-bands-l { display: flex; margin-top: 3px; font-size: 10px; color: var(--text-3); }
.ig-bands-l span { text-align: center; flex: none; overflow: hidden; white-space: nowrap; }
@media (pointer: coarse), (max-width: 760px) { .ig-bands { margin-left: 16px; margin-right: 16px; } }
/* tallone da dietro che si inclina con il cuneo */
.ig-heelrow { display: flex; align-items: center; gap: 8px; margin-top: -4px; font-size: 10.5px; color: var(--text-3); }
.ig-heelrow b { margin-left: auto; font-weight: 600; color: var(--text-2); font-variant-numeric: tabular-nums; }
.ig-heelrow b.on { color: var(--accent); }
/* barra impilata delle fasce di densità (Esporta) */
.ig-stack { display: flex; flex-direction: column; gap: 3px; }
.ig-stack-bar { display: flex; height: 18px; border-radius: 4px; overflow: hidden; }
.ig-stack-bar i { display: flex; align-items: center; justify-content: center; height: 100%; flex: none; font-size: 10.5px; font-weight: 600; color: #fff; text-shadow: 0 1px 1px rgba(0,0,0,.4); overflow: hidden; white-space: nowrap; }
.ig-stack-l { display: flex; font-size: 10px; color: var(--text-3); }
.ig-stack-l span { text-align: center; flex: none; overflow: hidden; white-space: nowrap; }
.ig-stack-l.ends { justify-content: space-between; }
/* anello del conto alla rovescia su «Rimanda» (codice via email): secondi al centro, poi l'icona */
.ig-again-row { display: flex; align-items: center; gap: 10px; }
.ig-again { position: relative; width: 36px; height: 36px; border-radius: 50%; }
.ig-again .ig-ring-svg { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); pointer-events: none; }
.ig-again .ig-ring-bg { fill: none; stroke: var(--line); stroke-width: 2; }
.ig-again .ig-ring { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; transition: stroke-dashoffset 1s linear; }
.ig-again .ig-sec { font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; }
.ig-again .bi { display: none; }
.ig-again.ready .ig-sec, .ig-again.ready .ig-ring-svg { display: none; }
.ig-again.ready .bi { display: inline-flex; }
.ig-again:disabled { cursor: default; }

/* Lotto 3 · moduli posturali (20-10): bacino cliccabile e sezione quotata (ui.js pelvisMap / ergoFig) */
.pelvis-map [data-preset]:hover ellipse, .pelvis-map [data-preset]:focus-visible ellipse { fill-opacity: .4; }
.pelvis-map [data-preset]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.ergo-fig text, .pelvis-map text { font-variant-numeric: tabular-nums; }
.seg.full button:has(.bi) svg { width: 18px; height: 18px; }

/* pulsante con parola «acceso» (20-10: Pennello dei cuscini, Carbonio del tutore, DX + SX dei plantari) */
.btn.on { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }

/* ---------- Lotto 4 semplificazione (20-10): componenti comuni (shell.js) ---------- */
/* toast con icona: ok (spunta verde), err (triangolo rosso, resta finché non si chiude con la X), info; la regola base è sopra */
.toast .bi svg { width: 18px; height: 18px; flex: none; }
.toast.ok .bi { color: var(--ok); }
.toast.err .bi { color: var(--err); }
.toast.err.show { pointer-events: auto; }   /* solo da visibile: la X si deve poter premere */
.toast-x { border: 0; background: none; color: #fff; opacity: .7; cursor: pointer; display: inline-flex; padding: 2px; margin-left: 4px; }
.toast-x:hover { opacity: 1; }
.toast-x svg { width: 16px; height: 16px; }
/* ---------- «Installa FORMAXIS su questo PC» (js/ui/installazione.js): barra in basso al centro, solo online ---------- */
.installa { position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%); display: flex; align-items: center; gap: 10px; background: var(--tip-bg); color: #fff; padding: 8px 10px 8px 14px; border-radius: 8px; font-size: 13px; box-shadow: 0 8px 24px rgba(0,0,0,.25); z-index: 60; max-width: calc(100vw - 32px); }
.installa .bi svg { width: 18px; height: 18px; flex: none; }
.installa .btn.primary { height: 28px; margin-left: 4px; }
/* domande (conferma, nome, modifiche non salvate) */
.dlg-text { margin: 0; font-size: 13.5px; line-height: 1.5; white-space: pre-line; }
.btn.primary.danger { background: var(--err); border-color: var(--err); color: #fff; box-shadow: none; }
.btn.primary.danger:hover { background: var(--err); border-color: var(--err); filter: brightness(1.08); box-shadow: 0 3px 10px rgba(240,93,93,.3); }
.modal header .icon-btn { flex: none; }
/* tastierino di allineamento (plantari: scansione, foto, esame): etichetta · meno · casella · più */
.nudge { display: flex; flex-direction: column; gap: 6px; }
.nudge-row { display: grid; grid-template-columns: 1fr auto auto auto; gap: 6px; align-items: center; }
.nudge-row .val input[type=number] { width: 60px; }
.nudge .r-up svg, .nudge .r-left svg { transform: rotate(180deg); }
.nudge-foot .seg button { min-width: 36px; }
