:root {
  color-scheme: dark;
  --ground: #141219;
  --surface: #1d1a24;
  --surface-2: #26222f;
  --line: #34303f;
  --ink: #efeaf4;
  --muted: #9c95aa;
  --led: #3fb8ec;      /* stesso azzurro del livello engraving */
  --cut: #f0509c;      /* stesso magenta del livello CUT */
  --ok: #6fd49a;
  --warn: #f2b44c;
  --radius: 10px;
  --display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --body: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--ground);
  color: var(--ink);
  font: 15px/1.5 var(--body);
  padding-inline: 16px;
  padding-block: 28px 48px;
}
.wrap { max-width: 1080px; margin: 0 auto; display: grid; gap: 24px; }
header { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px 24px; }
h1 {
  font: 700 clamp(26px, 4vw, 36px)/1.1 var(--display);
  margin: 0; letter-spacing: -0.01em; text-wrap: balance;
}
h1 .glow { color: var(--cut); text-shadow: 0 0 18px rgba(240, 80, 156, .55); }
.sub { color: var(--muted); margin: 0; }
h2 {
  font: 600 12px/1.2 var(--body); text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted); margin: 0 0 12px;
}
.grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 24px; align-items: start; }
@media (max-width: 820px) { .grid { grid-template-columns: minmax(0, 1fr); } }
.col { display: grid; gap: 24px; min-width: 0; }
section.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }

/* Caricamento file */
.drop {
  display: grid; place-items: center; text-align: center; gap: 6px;
  border: 1.5px dashed var(--line); border-radius: var(--radius);
  padding: 28px 16px; cursor: pointer; transition: border-color .15s, background .15s;
}
.drop:hover, .drop.over { border-color: var(--led); background: rgba(63, 184, 236, .06); }
.drop:focus-within { outline: 2px solid var(--led); outline-offset: 2px; }
.drop strong { font: 600 16px/1.3 var(--display); }
.drop span { color: var(--muted); font-size: 13px; }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.filename { font-family: var(--mono); font-size: 13px; color: var(--ink); word-break: break-all; }
.preview {
  margin-top: 16px; background: #fff; border-radius: 6px; overflow: hidden;
  display: grid; place-items: center; min-height: 80px;
}
.preview canvas { display: block; max-width: 100%; height: auto; }
.msg { margin-top: 14px; padding: 10px 12px; border-radius: 8px; font-size: 14px; border: 1px solid; }
.msg.err { color: #ffb3c9; border-color: rgba(240, 80, 156, .5); background: rgba(240, 80, 156, .08); }
.msg.warn { color: #ffd99a; border-color: rgba(242, 180, 76, .5); background: rgba(242, 180, 76, .08); }

/* Misure */
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.field { display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; min-width: 0; }
.field label { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.dot.led { background: var(--led); box-shadow: 0 0 8px var(--led); }
.dot.cut { background: var(--cut); box-shadow: 0 0 8px var(--cut); }
.input-unit { display: flex; align-items: stretch; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; }
.input-unit:focus-within { border-color: var(--led); }
.input-unit.richiesto { border-color: var(--warn); box-shadow: 0 0 0 1px var(--warn) inset; }
.input-unit input {
  flex: 1; min-width: 0; background: transparent; border: 0; color: var(--ink);
  font: 500 16px var(--mono); padding: 9px 10px; outline: none;
}
.input-unit em { font-style: normal; color: var(--muted); font: 13px var(--mono); padding: 0 10px; display: grid; place-items: center; }
.field small { color: var(--muted); font: 12px var(--mono); }
.field.full { grid-column: 1 / -1; }
.layer-pick { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; margin-top: 14px; }
select {
  width: 100%; background: var(--surface-2); color: var(--ink); border: 1px solid var(--line);
  border-radius: 8px; padding: 9px 10px; font: 14px var(--body);
}

/* Scelte */
.seg { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.seg.four { grid-template-columns: repeat(4, 1fr); }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label {
  display: grid; gap: 2px; justify-items: center; text-align: center;
  padding: 12px 6px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface-2);
  cursor: pointer; transition: border-color .15s, background .15s, box-shadow .15s;
}
.seg label b { font: 700 18px var(--display); }
.seg label span { font: 12px var(--mono); color: var(--muted); }
.seg input:checked + label { border-color: var(--cut); background: rgba(240, 80, 156, .1); box-shadow: 0 0 0 1px var(--cut) inset, 0 0 16px rgba(240, 80, 156, .25); }
.seg input:focus-visible + label { outline: 2px solid var(--led); outline-offset: 2px; }
.hint { color: var(--muted); font-size: 13px; margin: 10px 0 0; min-height: 1.5em; }

/* Prezzo */
.price-main { display: grid; gap: 2px; }
.price-main .label { color: var(--muted); font-size: 13px; }
.price-main .value {
  font: 700 clamp(40px, 7vw, 56px)/1 var(--display); letter-spacing: -0.02em;
  color: var(--ink); text-shadow: 0 0 24px rgba(240, 80, 156, .35);
  font-variant-numeric: tabular-nums;
}
.price-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 18px; }
.kpi { background: var(--surface-2); border-radius: 8px; padding: 10px 12px; min-width: 0; }
.kpi .label { color: var(--muted); font-size: 12px; }
.kpi .value { font: 500 19px var(--mono); font-variant-numeric: tabular-nums; }
@media (max-width: 420px) { .price-row { grid-template-columns: 1fr 1fr; } }
table { width: 100%; border-collapse: collapse; margin-top: 18px; font-size: 14px; }
th, td { padding: 7px 0; border-bottom: 1px solid var(--line); text-align: left; }
th { font-weight: 500; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
td.n, th.n { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
tr.tot td { border-bottom: 0; font-weight: 600; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; align-items: center; }
button {
  font: 600 14px var(--body); color: var(--ground); background: var(--led); border: 0;
  border-radius: 8px; padding: 10px 14px; cursor: pointer;
}
button:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
button.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.copied { color: var(--ok); font-size: 13px; }
.msg.ok { color: #b9f0cf; border-color: rgba(111, 212, 154, .5); background: rgba(111, 212, 154, .08); }
.msg a { color: inherit; font-weight: 600; }
button:disabled { opacity: .5; cursor: default; }
.nav { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 20px; }
.nav a { color: var(--led); text-decoration: none; font-weight: 500; }
.nav a:hover { text-decoration: underline; }
textarea {
  width: 100%; background: var(--surface-2); color: var(--ink); border: 1px solid var(--line);
  border-radius: 8px; padding: 9px 10px; font: 14px/1.4 var(--body); resize: vertical;
}
textarea:focus { border-color: var(--led); outline: none; }
.foot { color: var(--muted); font-size: 12.5px; }
.foot code { font-family: var(--mono); }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---------- Barra di navigazione ---------- */
.topbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 4px;
  max-width: 1180px; margin: 0 auto 4px; padding-bottom: 14px; border-bottom: 1px solid var(--line);
}
.topbar .brand { font: 700 17px var(--display); margin-right: 14px; color: var(--ink); text-decoration: none; }
.topbar .brand span { color: var(--cut); text-shadow: 0 0 12px rgba(240, 80, 156, .5); }
.topbar a.link { color: var(--muted); text-decoration: none; padding: 6px 10px; border-radius: 8px; font-weight: 500; font-size: 14px; }
.topbar a.link:hover { color: var(--ink); background: var(--surface); }
.topbar a.link[aria-current="page"] { color: var(--ink); background: var(--surface-2); }
.topbar .chi { margin-left: auto; display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.topbar .chi button { background: none; border: 1px solid var(--line); color: var(--ink); padding: 5px 10px; font-weight: 500; font-size: 13px; }

/* ---------- Componenti comuni ---------- */
.wrap.largo { max-width: 1180px; }
.btn-link { display: inline-block; font: 600 14px var(--body); color: var(--ground); background: var(--led); border-radius: 8px; padding: 10px 14px; text-decoration: none; }
.btn-link:hover { filter: brightness(1.08); }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 99px; font: 500 12.5px var(--body); border: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.preventivato { color: #c9c2d6; }
.pill.confermato { color: var(--led); }
.pill.pagato { color: var(--ok); }
.pill.consegnato { color: #b49cff; }
.swatch { display: inline-block; width: 14px; height: 14px; border-radius: 50%; border: 1px solid rgba(255,255,255,.25); vertical-align: -2px; flex: none; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.vuoto { padding: 36px 16px; text-align: center; color: var(--muted); }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.table-wrap table { margin-top: 0; }
.table-wrap th, .table-wrap td { padding: 10px 12px; }
.table-wrap tbody tr:last-child td { border-bottom: 0; }
.table-wrap tbody tr.click { cursor: pointer; }
.table-wrap tbody tr.click:hover { background: var(--surface-2); }
.form-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.form-row .field { flex: 1 1 160px; }
input.plain, select.plain {
  width: 100%; background: var(--surface-2); color: var(--ink); border: 1px solid var(--line);
  border-radius: 8px; padding: 9px 10px; font: 14px var(--body);
}
input.plain:focus, select.plain:focus { border-color: var(--led); outline: none; }
input[type="color"].plain { padding: 2px; height: 39px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: grid; gap: 6px; }
.card .label { color: var(--muted); font-size: 13px; }
.card .big { font: 700 28px/1.1 var(--display); font-variant-numeric: tabular-nums; }
.card.basso { border-color: rgba(242, 180, 76, .6); }
.neg { color: #ff9cbc; }
.pos { color: var(--ok); }
.riga-colore { display: grid; grid-template-columns: 18px minmax(0, 1fr) 110px 32px; gap: 8px; align-items: center; }
.riga-colore + .riga-colore { margin-top: 8px; }
.icon-btn { background: none; border: 1px solid var(--line); color: var(--muted); border-radius: 8px; padding: 0; width: 32px; height: 36px; font-size: 18px; line-height: 1; }
.icon-btn:hover { color: var(--cut); border-color: var(--cut); }
.stepper { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.stepper button { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); padding: 10px 6px; font-size: 13.5px; }
.stepper button.fatto { color: var(--ink); }
.stepper button.attivo { color: var(--ground); background: var(--cut); border-color: var(--cut); box-shadow: 0 0 16px rgba(240, 80, 156, .35); }
@media (max-width: 520px) { .stepper { grid-template-columns: 1fr 1fr; } }
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; font-size: 14px; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; }
a { color: var(--led); }
.input-unit { min-width: 0; }
.input-unit input { width: 100%; }

/* ---------- Anteprima 3D ---------- */
.vista3d {
  position: relative; aspect-ratio: 4 / 3; max-width: 100%; border-radius: 8px; overflow: hidden;
  background: radial-gradient(ellipse at 50% 40%, #26222f, #0b0a0e 70%); display: grid; place-items: center;
}
.vista3d.aperta { background: #0b0a0e; touch-action: none; }
.vista3d .canvas3d, .vista3d .svg2d { display: block; width: 100%; height: 100%; }
.vista3d .canvas3d { cursor: grab; }
.vista3d .canvas3d:active { cursor: grabbing; }
.apri3d { font-size: 15px; padding: 12px 18px; }
.controlli3d { display: grid; gap: 12px; margin-top: 12px; }
.riga3d { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; justify-content: space-between; }
.preset { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.preset-col {
  width: 26px; height: 26px; padding: 0; border-radius: 50%; border: 2px solid var(--line);
  background: var(--c); box-shadow: 0 0 10px color-mix(in srgb, var(--c) 60%, transparent);
}
.preset-col[aria-pressed="true"] { border-color: var(--ink); transform: scale(1.12); }
.preset-libero { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; border: 1px dashed var(--muted); overflow: hidden; cursor: pointer; }
.preset-libero input { width: 44px; height: 44px; border: 0; padding: 0; background: none; cursor: pointer; }
button.mini { padding: 5px 10px; font-size: 12.5px; }
.interruttore { min-width: 92px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.interruttore[aria-pressed="true"] { color: var(--ground); background: var(--cut); border-color: var(--cut); box-shadow: 0 0 14px rgba(240, 80, 156, .45); }
.campi3d { justify-content: flex-start; }
.campi3d label { display: grid; gap: 4px; font-size: 12.5px; color: var(--muted); flex: 1 1 140px; min-width: 0; }
.campi3d select.plain, .campi3d .input-unit input { font-size: 13.5px; padding: 7px 8px; }
.disclaimer { margin: 10px 0 0; font-size: 12px; color: var(--muted); }
