/* Stile ispirato a shadcn/ui (palette zinc, bordi sottili, raggio 8px, font Inter) */
@font-face { font-family: "Inter"; src: url("vendor/fonts/inter-latin-wght-normal.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
:root {
  --background: #ffffff; --foreground: #09090b;
  --muted: #f4f4f5; --muted-fg: #71717a;
  --border: #e4e4e7; --input: #e4e4e7; --ring: #a1a1aa;
  --primary: #18181b; --primary-fg: #fafafa;
  --secondary: #f4f4f5; --accent: #f4f4f5;
  --destructive: #dc2626;
  --luce: #ca8a04; --clima: #0284c7; --altro: #7c3aed; --ok: #16a34a; --warn: #ea580c;
  --radius: 8px;
  --safe-t: env(safe-area-inset-top); --safe-b: env(safe-area-inset-bottom);
  --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
html, body { margin: 0; height: 100%; background: var(--background); color: var(--foreground);
  font: 14px/1.45 "Inter", -apple-system, system-ui, "Segoe UI", Roboto, sans-serif; font-feature-settings: "cv11", "ss01"; overscroll-behavior: none; -webkit-font-smoothing: antialiased; }
body { -webkit-user-select: none; user-select: none; }
input, textarea, select { -webkit-user-select: text; user-select: text; font: inherit; color: inherit; }
.hidden { display: none !important; }
.ic { flex: 0 0 auto; display: block; }
.screen { position: fixed; inset: 0; display: flex; flex-direction: column; background: var(--background); }

/* barra superiore */
.bar { display: flex; align-items: center; gap: 8px; padding: calc(10px + var(--safe-t)) 16px 10px; background: var(--background); border-bottom: 1px solid var(--border); flex-wrap: wrap; min-height: 60px; }
.bar h1 { font-size: 17px; font-weight: 600; letter-spacing: -.01em; margin: 0 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 34vw; }
.bar .sub { color: var(--muted-fg); font-size: 13px; }
.spacer { flex: 1; }

/* bottoni (varianti shadcn) */
button, .btn { font: inherit; font-weight: 500; border: 1px solid transparent; border-radius: var(--radius); padding: 0 14px; height: 40px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; white-space: nowrap; transition: background .12s, border-color .12s, color .12s; }
button:focus-visible, .btn:focus-within { outline: 2px solid var(--ring); outline-offset: 2px; }
.primary { background: var(--primary); color: var(--primary-fg); }
.primary:active { background: #27272a; }
.outline { background: var(--background); border-color: var(--input); color: var(--foreground); box-shadow: var(--shadow-sm); }
.outline:active, .ghost:active { background: var(--accent); }
.secondary { background: var(--secondary); color: var(--foreground); }
.ghost { background: transparent; color: var(--foreground); }
.danger { background: var(--background); border-color: #fecaca; color: var(--destructive); }
.icon-btn { width: 40px; padding: 0; }
.sm { height: 34px; padding: 0 10px; font-size: 13px; }

.content { flex: 1; overflow: auto; padding: 20px; padding-bottom: calc(28px + var(--safe-b)); -webkit-overflow-scrolling: touch; background: #fafafa; }
.content-inner { max-width: 1100px; margin: 0 auto; }
h2 { font-size: 15px; font-weight: 600; margin: 28px 0 10px; letter-spacing: -.01em; }
.hint { color: var(--muted-fg); font-size: 13px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 12px; margin-top: 14px; }
.card { background: var(--background); border-radius: 12px; padding: 16px; box-shadow: var(--shadow-sm); border: 1px solid var(--border); cursor: pointer; transition: border-color .12s; }
.card:active { border-color: var(--ring); }
.card h3 { margin: 0 0 4px; font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.card .meta { color: var(--muted-fg); font-size: 13px; }
.card .acts { display: flex; gap: 8px; margin-top: 12px; }
.row-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.empty { padding: 36px; text-align: center; color: var(--muted-fg); background: var(--background); border-radius: 12px; border: 1px dashed #d4d4d8; }
.badge { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--border); border-radius: 999px; padding: 1px 8px; font-size: 12px; font-weight: 500; color: var(--muted-fg); background: var(--background); }

/* tabs (modalità) */
.tabs { display: inline-flex; background: var(--muted); border-radius: 10px; padding: 4px; gap: 2px; }
.tabs button { height: 34px; background: transparent; color: var(--muted-fg); padding: 0 12px; border-radius: 7px; font-size: 13px; border: 0; }
.tabs button.on { background: var(--background); color: var(--foreground); box-shadow: 0 1px 3px rgba(0,0,0,.1); }
.switch { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted-fg); cursor: pointer; height: 40px; padding: 0 4px; }
.switch .track { width: 36px; height: 20px; border-radius: 999px; background: #e4e4e7; position: relative; transition: background .15s; }
.switch .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: transform .15s; }
.switch.on .track { background: var(--primary); }
.switch.on .track::after { transform: translateX(16px); }
.switch.on { color: var(--foreground); }

/* pianta */
.plan-wrap { position: relative; flex: 1 1 0; display: flex; min-height: 0; overflow: hidden; }
#cv { flex: 1 1 0; min-width: 0; min-height: 0; display: block; width: 100%; height: 100%; background: #fff; touch-action: none; }
.mode-hint { position: absolute; left: 12px; top: 56px; background: rgba(9,9,11,.88); color: #fafafa; padding: 9px 14px; border-radius: 12px; font-size: 13px; line-height: 1.4; max-width: min(360px, calc(100% - 24px)); text-align: left; box-shadow: 0 4px 12px rgba(0,0,0,.15); z-index: 6; }
.mode-hint:empty { display: none; }
.panel { flex: 0 0 auto; width: 380px; max-width: 46vw; background: var(--background); border-left: 1px solid var(--border); overflow: auto; padding: 16px; padding-bottom: calc(24px + var(--safe-b)); -webkit-overflow-scrolling: touch; }
@media (max-width: 760px), (orientation: portrait) and (max-width: 900px) {
  .plan-wrap { flex-direction: column; }
  .panel { width: 100%; max-width: none; height: 46%; border-left: 0; border-top: 1px solid var(--border); }
  .tabs button span { display: none; }
  .tabs button { padding: 0 10px; }
}
.panel-head { display: flex; align-items: center; gap: 6px; margin: -4px 0 12px; }
.panel-head h3 { margin: 0; font-size: 16px; font-weight: 600; flex: 1; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field label { font-size: 13px; font-weight: 500; }
.field input, .field textarea, .field select { border: 1px solid var(--input); border-radius: var(--radius); padding: 0 12px; height: 40px; background: var(--background); width: 100%; font-size: 16px; box-shadow: var(--shadow-sm); }
.field textarea { padding: 10px 12px; height: auto; }
.field input:focus, .field textarea:focus, .field select:focus { outline: 2px solid var(--ring); outline-offset: 1px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.toggle { display: grid; grid-template-columns: 1fr 1fr; background: var(--muted); border-radius: var(--radius); padding: 3px; height: 40px; }
.toggle button { height: 34px; background: transparent; padding: 0 10px; color: var(--muted-fg); border: 0; border-radius: 6px; font-size: 13px; }
.toggle button.on { background: var(--background); color: var(--foreground); box-shadow: 0 1px 3px rgba(0,0,0,.1); }
.sep { height: 1px; background: var(--border); margin: 14px 0; }
.addbar { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0; }
.addbar button { background: var(--background); border-color: var(--input); box-shadow: var(--shadow-sm); }
.addbar .add-luce .ic { color: var(--luce); } .addbar .add-clima .ic { color: var(--clima); } .addbar .add-altro .ic { color: var(--altro); }
.voce { background: var(--background); border-radius: 10px; border: 1px solid var(--border); margin-bottom: 8px; box-shadow: var(--shadow-sm); }
.voce-head { display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 12px; }
.voce-ic { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: #f3e8ff; color: var(--altro); }
.voce.luce .voce-ic { background: #fef9c3; color: var(--luce); } .voce.clima .voce-ic { background: #e0f2fe; color: var(--clima); }
.voce-name { flex: 1; min-width: 0; cursor: pointer; }
.voce-name b { display: block; font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.voce-name span { font-size: 12px; color: var(--muted-fg); }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--input); border-radius: var(--radius); height: 38px; }
.stepper button { height: 36px; width: 36px; padding: 0; font-size: 18px; background: transparent; border: 0; color: var(--foreground); }
.stepper input { width: 40px; text-align: center; border: 0; background: transparent; font-size: 15px; font-weight: 600; padding: 0; height: 36px; }
.voce-body { padding: 12px; border-top: 1px solid var(--border); background: #fafafa; border-radius: 0 0 10px 10px; }
.stat { display: flex; justify-content: space-between; align-items: baseline; border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; margin: 4px 0 4px; }
.stat .lbl { color: var(--muted-fg); font-size: 13px; }
.stat b { font-size: 20px; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.photos { display: flex; gap: 6px; flex-wrap: wrap; }
.photos img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); }
.list-locali .li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; margin-bottom: 6px; cursor: pointer; }
.list-locali .li b { font-weight: 500; }
.counts { display: inline-flex; gap: 8px; color: var(--muted-fg); font-size: 12px; font-variant-numeric: tabular-nums; }
.counts span { display: inline-flex; align-items: center; gap: 3px; }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
table.sum { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--background); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; font-size: 14px; }
table.sum th { font-weight: 500; color: var(--muted-fg); background: #fafafa; }
table.sum th, table.sum td { padding: 10px 14px; border-bottom: 1px solid var(--border); text-align: left; }
table.sum tr:last-child th, table.sum tr:last-child td { border-bottom: 0; }
table.sum tr:last-child th { color: var(--foreground); font-weight: 600; }
table.sum .n { text-align: right; font-variant-numeric: tabular-nums; }

/* dialog */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.modal-box { background: var(--background); border-radius: 14px; width: min(600px, 100%); max-height: 88vh; display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 20px 50px rgba(0,0,0,.25); border: 1px solid var(--border); }
.modal-head { display: flex; align-items: center; gap: 8px; padding: 18px 18px 6px; }
.modal-head h3 { margin: 0; flex: 1; font-size: 17px; font-weight: 600; letter-spacing: -.01em; }
.modal-body { overflow: auto; padding: 8px 18px 18px; -webkit-overflow-scrolling: touch; }
.search-wrap { position: relative; margin-bottom: 10px; }
.search-wrap .ic { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted-fg); }
.search { width: 100%; border: 1px solid var(--input); border-radius: var(--radius); height: 44px; padding: 0 12px 0 38px; font-size: 16px; background: var(--background); box-shadow: var(--shadow-sm); }
.search:focus { outline: 2px solid var(--ring); outline-offset: 1px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.chip { height: 30px; padding: 0 12px; border-radius: 999px; font-size: 13px; background: var(--background); border: 1px solid var(--border); color: var(--muted-fg); }
.chip.on { background: var(--primary); border-color: var(--primary); color: var(--primary-fg); }
.pick { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--radius); cursor: pointer; border: 1px solid transparent; }
.pick + .pick { border-top-color: var(--border); border-radius: 0; }
.pick:active { background: var(--accent); }
.pick.custom { border: 1px dashed #d4d4d8; border-radius: var(--radius); margin-bottom: 6px; }
.pick .nm { flex: 1; min-width: 0; }
.pick .nm b { display: block; font-size: 14px; font-weight: 500; }
.pick .nm span { font-size: 12px; color: var(--muted-fg); }
.pick .pw { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; font-size: 13px; }
.layer-row { display: flex; align-items: center; gap: 10px; padding: 8px 2px; border-bottom: 1px solid var(--border); }
.layer-row input { width: 20px; height: 20px; accent-color: var(--primary); }
.layer-row .sw { width: 12px; height: 12px; border-radius: 3px; }
.layer-row .ln { flex: 1; font-size: 14px; }
.layer-row .ct { color: var(--muted-fg); font-size: 12px; }
.toast { position: fixed; left: 50%; top: calc(68px + var(--safe-t)); transform: translateX(-50%); background: var(--background); color: var(--foreground); border: 1px solid var(--border); padding: 12px 16px; border-radius: 10px; z-index: 60; font-size: 14px; max-width: 90vw; box-shadow: 0 10px 30px rgba(0,0,0,.12); }

/* pannello richiudibile e comandi rapidi */
.plan-wrap.closed .panel { display: none; }
.tabs .icon-tab { width: 38px; padding: 0; }
.quickbar { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(78px + var(--safe-b)); z-index: 5; display: flex; align-items: center; gap: 6px;
  background: var(--background); border: 1px solid var(--border); border-radius: 14px; padding: 6px; box-shadow: 0 10px 30px rgba(0,0,0,.15); max-width: calc(100% - 24px); }
.quickbar .qname { padding: 0 8px 0 10px; display: flex; flex-direction: column; min-width: 0; }
.quickbar .qname b { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }
.quickbar .qname span { font-size: 12px; color: var(--muted-fg); }
.quickbar button { height: 40px; }
.quickbar .q-luce .ic { color: var(--luce); } .quickbar .q-clima .ic { color: var(--clima); } .quickbar .q-altro .ic { color: var(--altro); }
.quickbar .vsep { width: 1px; align-self: stretch; background: var(--border); margin: 4px 2px; }
.undo-group { display: inline-flex; gap: 6px; margin-left: 4px; }
button:disabled { opacity: .4; cursor: default; }

/* competenze, verifica, selezione */
.comp-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-comp { height: 32px; padding: 0 10px; font-size: 12px; border: 1px solid var(--border); background: var(--background); border-radius: 999px; gap: 6px; }
.chip-comp i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; border: 1px solid rgba(0,0,0,.15); }
.chip-comp.on { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); font-weight: 600; }
.verifica { background: #fff7ed; border: 1px solid #fed7aa; color: #9a3412; border-radius: 10px; padding: 10px 12px; font-size: 13px; margin-bottom: 12px; display: block; }
.verifica .primary { float: right; margin-top: -4px; }
.list-locali .li { align-items: center; }
.list-locali .li.auto { border-style: dashed; }
.list-locali .li b { flex: 1; }
.cdot { width: 12px; height: 12px; border-radius: 3px; flex: 0 0 auto; border: 1px solid rgba(0,0,0,.15); }
.quickbar .chip-comp { height: 36px; }
.quickbar { flex-wrap: wrap; justify-content: center; }

/* area pianta: barra strumenti fissa in basso, info richiudibile */
.cv-area { position: relative; flex: 1 1 0; min-width: 0; min-height: 0; overflow: hidden; }
.cv-area #cv { position: absolute; left: 0; top: 0; width: 100%; height: 100%; }
.toolbar-bottom { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(12px + var(--safe-b)); display: flex; align-items: center; gap: 10px;
  background: var(--background); border: 1px solid var(--border); border-radius: 14px; padding: 6px 10px 6px 6px; box-shadow: 0 10px 30px rgba(0,0,0,.14); z-index: 5; white-space: nowrap; max-width: calc(100% - 24px); }
.toolbar-bottom .tabs { flex-wrap: nowrap; }
.toolbar-bottom .tabs button { height: 40px; }
.toolbar-bottom .tabs .icon-tab { width: 42px; }
.info-dot { position: absolute; left: 12px; top: 12px; width: 34px; height: 34px; padding: 0; border-radius: 999px; font: italic 600 16px/1 Georgia, serif; z-index: 6;
  background: var(--background); color: var(--foreground); border: 1px solid var(--border); box-shadow: 0 2px 8px rgba(0,0,0,.12); }
.info-dot.on { background: var(--foreground); color: var(--background); }
.plan-stato { position: absolute; left: 54px; top: 12px; height: 34px; display: flex; align-items: center; background: rgba(9,9,11,.86); color: #fafafa; padding: 0 14px; border-radius: 999px; font-size: 13px; pointer-events: none; z-index: 6; max-width: calc(100% - 80px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 560px) { .toolbar-bottom .tabs button span { display: none; } .toolbar-bottom .tabs button { padding: 0 10px; } }

/* sezioni richiudibili del pannello locale */
.fold { border: 1px solid var(--border); border-radius: 10px; margin: 0 0 14px; background: var(--background); }
.fold > summary { list-style: none; cursor: pointer; padding: 11px 14px; font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary::before { content: ''; width: 7px; height: 7px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg); transition: transform .15s; margin-right: 2px; }
.fold[open] > summary::before { transform: rotate(45deg); }
.fold .fold-sub { font-weight: 400; color: var(--muted-fg); font-size: 13px; margin-left: auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 60%; }
.fold > :not(summary) { margin-left: 14px; margin-right: 14px; }
.fold > :last-child { margin-bottom: 12px; }
.fold .stat { margin-top: 0; }
/* progetti preparati dal PC */
.cloud-box { border: 1px dashed var(--border); border-radius: 12px; padding: 12px 14px; margin: 0 0 14px; }
.cloud-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cloud-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-top: 1px solid var(--border); }
.cloud-row:first-child { border-top: 0; }
.cloud-row span { color: var(--muted-fg); font-size: 13px; display: block; }
/* finestre: riga di pulsanti e testo secondario */
.row-btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.muted { color: #71717a; font-size: 14px; margin: 0 0 12px; }
.quickbar button.on { background: #eef2ff; color: #1d4ed8; }
