/* OrgMapDesign — stile dell'app.
   Layout: barra in alto (marchio, ricerca, azioni), tela SVG a sinistra, pannello a destra.
   Su telefono il pannello diventa un foglio in basso e la modifica è disattivata. */

:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --fg: #1f2630;
  --muted: #66707e;
  --line: #dcdfe4;
  --line-strong: #c3c9d1;
  --accent: #2f3a4a;          /* ardesia: colore dell'app; i cerchi usano il colore dell'organizzazione */
  --accent-ink: #ffffff;
  --accent-soft: #e4e8ee;
  --focus: #d99a1e;           /* ocra: evidenziazione di persone e ricerca; i progetti hanno colori propri */
  --focus-soft: #faeed2;
  --danger: #b4322a;
  --shadow: 0 4px 18px rgba(20, 30, 28, .10);
  --display: "Outfit", system-ui, sans-serif;
  --body: "Source Sans 3", system-ui, -apple-system, "Segoe UI", sans-serif;
  --radius: 8px;
  --circle-l0: 32%; /* luminosità del tono per livello (0 = vertice) */
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14181d; --panel: #1c2128; --fg: #e8ecf1; --muted: #98a3b1; --line: #2d343d; --line-strong: #414a56;
    --accent: #b4c2d6; --accent-ink: #141a22; --accent-soft: #2b3340; --focus: #e8b046; --focus-soft: #3d3119;
    --danger: #ff8a80; --shadow: 0 4px 18px rgba(0, 0, 0, .45);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #14181d; --panel: #1c2128; --fg: #e8ecf1; --muted: #98a3b1; --line: #2d343d; --line-strong: #414a56;
  --accent: #b4c2d6; --accent-ink: #141a22; --accent-soft: #2b3340; --focus: #e8b046; --focus-soft: #3d3119;
  --danger: #ff8a80; --shadow: 0 4px 18px rgba(0, 0, 0, .45);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 15px/1.45 var(--body); }

.app { display: grid; grid-template-columns: 1fr 400px; grid-template-rows: auto auto 1fr; height: 100%; }

/* ---------- barra in alto ---------- */
.top {
  grid-column: 1 / -1; display: flex; align-items: center; gap: 14px;
  padding-block: 8px; padding-left: max(14px, env(safe-area-inset-left, 0px)); padding-right: max(14px, env(safe-area-inset-right, 0px));
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; min-width: 0; }
.brand-mark svg { width: 26px; height: 26px; display: block; }
.brand-mark circle { fill: var(--accent); }
.brand-mark .m2 { fill: var(--accent); opacity: .55; }
.brand-name { font: 600 19px var(--display); letter-spacing: .01em; }
.org-name { color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }
.org-name::before { content: "·"; margin-right: 8px; }
.org-name:empty::before { content: none; }
.search-pop { position: absolute; right: max(12px, env(safe-area-inset-right, 0px)); top: 50px; z-index: 30; width: min(420px, calc(100vw - 24px)); background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 8px; }
.search-pop input { width: 100%; box-sizing: border-box; font: inherit; color: var(--fg); background: var(--bg); border: 1px solid var(--line); border-radius: 20px; padding: 7px 14px; margin: 0; }
.search-results { max-height: min(60vh, 420px); overflow: auto; margin-top: 6px; }
.search-results:empty { display: none; }
.search-results h4 { font: 600 11px var(--body); text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 8px 8px 2px; }
.search-results button { display: flex; width: 100%; align-items: baseline; gap: 8px; text-align: left; background: none; border: 0; border-radius: 6px; padding: 6px 8px; font: 14px var(--body); color: var(--fg); cursor: pointer; }
.search-results button:hover, .search-results button.on { background: var(--accent-soft); }
.search-results button .kind { font-size: 11px; color: var(--muted); flex: none; min-width: 52px; }
.search-results button .where { font-size: 12px; color: var(--muted); margin-left: auto; flex: none; max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-results .empty { padding: 8px; font-size: 13px; }
.top-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.pill { font-size: 12px; color: var(--focus); background: var(--focus-soft); border-radius: 12px; padding: 2px 10px; white-space: nowrap; }

/* ---------- banner (versione storica / link condiviso) ---------- */
.banner { grid-column: 1 / -1; background: var(--focus-soft); color: var(--fg); padding: 8px max(14px, env(safe-area-inset-left, 0px)); font-size: 14px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; border-bottom: 1px solid var(--line); }
.banner button { padding: 3px 10px; }

/* ---------- tela ---------- */
.canvas { position: relative; min-width: 0; overflow: hidden; }
.canvas svg { width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; }
.canvas svg.dragging { cursor: grabbing; }
.canvas svg.drag-circle { cursor: move; }
.legend { position: absolute; left: max(12px, env(safe-area-inset-left, 0px)); bottom: 12px; max-width: 300px; font-size: 12px; color: var(--muted); background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px; display: none; gap: 6px; box-shadow: var(--shadow); }
.legend.on { display: grid; }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend i { width: 18px; height: 18px; border-radius: 50%; flex: none; display: inline-grid; place-items: center; font: 600 8px var(--body); font-style: normal; box-sizing: border-box; }
.legend .l-link { background: var(--accent); }
.legend .l-op { background: var(--panel); border: 2px solid var(--accent); color: var(--fg); }
.legend .l-vac { background: var(--panel); border: 2px dashed var(--accent); }
.legend .l-mem { background: var(--panel); border: 1.5px solid var(--accent); color: var(--fg); }
.zoom { position: absolute; right: 12px; bottom: 12px; display: flex; flex-direction: column; gap: 4px; }
.zoom button { width: 32px; height: 32px; padding: 0; font-size: 18px; line-height: 1; }
.focus-chip { position: absolute; left: max(12px, env(safe-area-inset-left, 0px)); top: 68px; background: var(--panel); border: 1px solid var(--focus); color: var(--fg); border-radius: 20px; padding: 5px 8px 5px 12px; font-size: 13px; display: flex; align-items: center; gap: 8px; box-shadow: var(--shadow); }
.focus-chip b { color: var(--focus); font-weight: 600; }
.focus-chip button { padding: 0 7px; border-radius: 12px; font-size: 13px; }

/* elementi SVG */
.c-shape { cursor: pointer; stroke-width: 2.5; }
.c-shape.selected { stroke: var(--accent) !important; stroke-width: 4; }
.c-shape.editable { cursor: move; }
.c-label { font: 600 13px var(--display); fill: var(--fg); pointer-events: none; }
.c-sub { font: 11px var(--body); fill: var(--muted); pointer-events: none; }
.member-chip { cursor: pointer; }
.member-chip.selected { stroke: var(--accent); stroke-width: 2.5; }
.member-chip-text { font: 600 8px var(--body); pointer-events: none; text-anchor: middle; dominant-baseline: central; }
.r-dot { cursor: pointer; stroke-width: 2; }
.r-dot.selected { stroke: var(--accent) !important; stroke-width: 3.5; }
.r-dot.editable { cursor: move; }
.r-dot.vacant { stroke-dasharray: 3 2.5; }
.r-abbr { font: 600 9px var(--body); pointer-events: none; text-anchor: middle; dominant-baseline: central; }
.r-icon { pointer-events: none; }
.r-label { font: 11px var(--body); fill: var(--fg); pointer-events: none; paint-order: stroke; stroke: var(--bg); stroke-width: 3px; stroke-linejoin: round; }
.dim { opacity: .22; }
.hl { filter: url(#glow); }
.hl-ring { fill: none; stroke: var(--focus); stroke-width: 4; pointer-events: none; }
.proj-link { fill: none; stroke: var(--focus); stroke-width: 1.5; stroke-dasharray: 4 4; pointer-events: none; opacity: .8; }
@media (prefers-reduced-motion: no-preference) { .c-shape, .r-dot { transition: stroke-width .12s, opacity .15s; } }

/* ---------- pannello laterale ---------- */
.side { border-left: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.tabs { display: flex; border-bottom: 1px solid var(--line); padding: 0 8px; gap: 2px; }
.tabs button { background: none; border: 0; border-bottom: 2px solid transparent; border-radius: 0; padding: 10px 10px; color: var(--muted); font: 600 13px var(--body); cursor: pointer; }
.tabs button.active { color: var(--fg); border-bottom-color: var(--accent); }
.tabs { overflow-x: auto; scrollbar-width: none; flex: none; }
.tabs button { padding: 10px 7px; font-size: 12.5px; white-space: nowrap; }
.panel { overflow-y: auto; min-height: 0; padding-block: 14px 40px; padding-left: 16px; padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.panel h2 { font: 600 18px var(--display); margin: 0 0 4px; text-wrap: balance; }
.panel h3 { font: 600 11px var(--body); text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 20px 0 6px; }
.crumb { color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.crumb a, .panel a.go { color: var(--accent); cursor: pointer; text-decoration: none; }
.panel a.go:hover, .crumb a:hover { text-decoration: underline; }
label { display: block; font-size: 12px; color: var(--muted); margin: 10px 0 3px; }
label .req { color: var(--danger); }
input[type=text], input[type=search], input[type=color], textarea, select {
  width: 100%; font: inherit; color: var(--fg); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 6px 9px;
}
input[type=color] { height: 36px; padding: 2px; width: 60px; }
textarea { resize: vertical; min-height: 54px; }
input:focus-visible, textarea:focus-visible, select:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
button { font: 600 13px var(--body); color: var(--fg); background: var(--panel); border: 1px solid var(--line-strong); border-radius: 6px; padding: 6px 11px; cursor: pointer; }
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.danger { color: var(--danger); border-color: var(--danger); }
button.ghost { border-color: transparent; color: var(--accent); padding: 4px 6px; }
button.toggle[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.small { padding: 3px 8px; font-size: 12px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; align-items: center; }
.note { font-size: 13px; color: var(--muted); }
.empty { color: var(--muted); font-style: italic; font-size: 13px; }
.read { white-space: pre-wrap; margin: 0 0 6px; }
.read:empty::before { content: "—"; color: var(--muted); }
ul.plain { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; }
ul.plain li { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
ul.plain li .note { text-align: right; }
.card { border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px; margin-bottom: 8px; }
.card.selected { border-color: var(--accent); background: var(--accent-soft); }
.card.link { border-left: 4px solid var(--accent); }
.card .head { display: flex; align-items: center; gap: 8px; }
.card .head .name { font-weight: 600; flex: 1; min-width: 0; }
.card .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.card .grid2 > * { min-width: 0; }
.card details { margin-top: 6px; }
.card summary { font-size: 12px; color: var(--muted); cursor: pointer; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 14px; padding: 2px 8px 2px 3px; font-size: 13px; cursor: pointer; background: var(--panel); }
.chip:hover { border-color: var(--accent); }
.chip.selected { border-color: var(--focus); background: var(--focus-soft); }
.chip .ini { width: 20px; height: 20px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 9px; font-weight: 600; background: var(--accent-soft); color: var(--fg); }
.chip .x { color: var(--muted); padding: 0 2px; }
.chip .x:hover { color: var(--danger); }
.iconpick { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.iconpick button { width: 30px; height: 30px; padding: 4px; }
.iconpick button svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.iconpick button.on { border-color: var(--accent); background: var(--accent-soft); }
.history-item { padding: 8px 0; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 1fr auto; gap: 4px 8px; }
.history-item .when { font-weight: 600; }
.history-item .what { color: var(--muted); font-size: 13px; grid-column: 1; }
.history-item.current { background: var(--focus-soft); margin: 0 -8px; padding: 8px; border-radius: 6px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.toast { position: fixed; left: 50%; bottom: max(18px, env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--fg); color: var(--bg); padding: 8px 14px; border-radius: 20px; font-size: 13px; box-shadow: var(--shadow); z-index: 20; }
.inline-help { font-size: 12px; color: var(--muted); margin-top: 2px; }
.warn { background: var(--focus-soft); border-radius: 6px; padding: 8px 10px; font-size: 13px; margin-top: 10px; }

/* ---------- telefono: solo consultazione ---------- */
@media (max-width: 800px) {
  .app { grid-template-columns: 1fr; grid-template-rows: auto auto 1fr auto; }
  .org-name { display: none; }
  #btnMode { display: none; }
  .side { border-left: 0; border-top: 1px solid var(--line); max-height: 46vh; }
  .panel { padding-left: max(16px, env(safe-area-inset-left, 0px)); }
}

/* ---------- v0.3: viste, strati, presentazione, elenco, stampa, rete ---------- */
.viewbox { position: absolute; right: 12px; top: 12px; display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.seg { display: inline-flex; background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 2px; box-shadow: var(--shadow); }
.seg button { border: 0; background: none; border-radius: 16px; padding: 4px 12px; font-size: 13px; color: var(--muted); }
.seg button.on { background: var(--accent); color: var(--accent-ink); }
.layers { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 5px 10px; font-size: 12px; color: var(--muted); box-shadow: var(--shadow); max-width: 320px; }
.layers label { display: inline-flex; align-items: center; gap: 4px; margin: 0; cursor: pointer; font-size: 12px; }
.layers input { margin: 0; }
.p-node { cursor: pointer; }
.p-node.selected circle.ring { stroke: var(--accent); stroke-width: 3.5; }
.p-label { font: 600 11px var(--body); fill: var(--fg); pointer-events: none; text-anchor: middle; paint-order: stroke; stroke: var(--bg); stroke-width: 3px; stroke-linejoin: round; }
.p-edge { stroke: var(--line-strong); fill: none; }
.r-chip { pointer-events: none; }
.hold-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 6px; align-items: center; margin-bottom: 4px; }
.hold-row .dates { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.hold-row .dates label { margin: 0; font-size: 11px; }
input[type=date] { width: 100%; font: inherit; color: var(--fg); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; }
.notes { margin-top: 4px; }
.note-item { font-size: 13px; border-left: 3px solid var(--line); padding: 2px 8px; margin: 4px 0; white-space: pre-wrap; }
.note-item .meta { color: var(--muted); font-size: 11px; display: flex; gap: 8px; }
.note-item .meta a { color: var(--danger); cursor: pointer; }
.diff-list { font-size: 13px; }
.diff-list li { margin-bottom: 2px; }
.diff-list .add { color: var(--accent); } .diff-list .del { color: var(--danger); }
.warn-list li { margin-bottom: 2px; }
.expiring { color: var(--focus); font-weight: 600; }
.avatar-row { display: flex; align-items: center; gap: 10px; }
.avatar-row img { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; border: 1px solid var(--line); }
/* presentazione */
.app.presenting { grid-template-columns: 1fr; grid-template-rows: 1fr; }
.app.presenting .top, .app.presenting .side, .app.presenting .banner, .app.presenting .viewbox, .app.presenting .viewbar, .app.presenting .zoom, .app.presenting .focus-chip { display: none !important; }
.present-bar { position: absolute; left: 50%; bottom: max(18px, env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); display: flex; align-items: center; gap: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 30px; padding: 8px 10px 8px 14px; box-shadow: var(--shadow); max-width: min(880px, 92vw); z-index: 5; }
.present-text { font-size: 16px; line-height: 1.35; flex: 1; min-width: 0; }
.present-step { display: block; font: 600 11px var(--body); letter-spacing: .07em; text-transform: uppercase; color: var(--accent); }
.present-bar button { border-radius: 20px; }
.app.presenting .c-label { font-weight: 700; }
/* foglio elenco */
.sheet { position: fixed; inset: 0; background: rgba(20, 26, 24, .45); z-index: 15; display: flex; align-items: flex-start; justify-content: center; overflow-y: auto; padding: 24px 12px; }
.sheet-inner { background: var(--panel); color: var(--fg); border-radius: 10px; max-width: 820px; width: 100%; padding: 20px 26px 30px; box-shadow: var(--shadow); }
.sheet-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 8px; }
.sheet h2 { font: 600 20px var(--display); margin: 0; }
.sheet h3 { font: 600 16px var(--display); margin: 20px 0 4px; padding-top: 10px; border-top: 1px solid var(--line); text-transform: none; letter-spacing: 0; color: var(--fg); }
.sheet h3 small { color: var(--muted); font: 13px var(--body); margin-left: 8px; }
.sheet dl { display: grid; grid-template-columns: 120px 1fr; gap: 2px 12px; font-size: 14px; margin: 4px 0; }
.sheet dt { color: var(--muted); } .sheet dd { margin: 0; }
.sheet ul { margin: 0; padding-left: 18px; }
.sheet table { width: 100%; border-collapse: collapse; font-size: 14px; margin-top: 4px; }
.sheet th, .sheet td { text-align: left; padding: 3px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.sheet th { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.print-head { display: none; }
@media (max-width: 800px) { .viewbox { right: 8px; top: 8px; } .layers { display: none; } #btnPresent { display: none; } }
/* stampa */
@media print {
  @page { size: A3 landscape; margin: 10mm; }
  html, body { height: auto; background: #fff; }
  body:not(.print-sheet) .app { display: block; }
  body:not(.print-sheet) .top, body:not(.print-sheet) .side, body:not(.print-sheet) .banner, body:not(.print-sheet) .viewbox, body:not(.print-sheet) .viewbar, body:not(.print-sheet) .zoom, body:not(.print-sheet) .focus-chip, body:not(.print-sheet) .present-bar, body:not(.print-sheet) .legend, .toast { display: none !important; }
  body:not(.print-sheet) .canvas { position: static; width: 100%; height: auto; overflow: visible; }
  body:not(.print-sheet) .canvas svg { width: 100%; height: 170mm; }
  body:not(.print-sheet) .print-head { display: block; font: 600 20px var(--display); margin: 0 0 6px; }
  body:not(.print-sheet) .print-head small { display: block; font: 12px var(--body); color: #555; }
  body.print-sheet .app { display: none; }
  body.print-sheet .sheet { position: static; background: none; padding: 0; display: block; }
  body.print-sheet .sheet-inner { box-shadow: none; max-width: none; padding: 0; }
  body.print-sheet .sheet-head .row { display: none; }
}


/* ---------- v0.4 ---------- */
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; font-weight: 600; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .knob { width: 38px; height: 22px; border-radius: 11px; background: var(--line-strong); position: relative; transition: background .15s; flex: none; }
.switch .knob::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.switch input:checked + .knob { background: var(--accent); }
.switch input:checked + .knob::after { transform: translateX(16px); }
.switch input:disabled + .knob { opacity: .4; }
.switch input:focus-visible + .knob { outline: 2px solid var(--accent); outline-offset: 2px; }
button.icon { width: 34px; height: 34px; padding: 6px; display: inline-grid; place-items: center; }
button.icon svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.map-title { position: absolute; left: max(14px, env(safe-area-inset-left, 0px)); top: 12px; max-width: min(46%, 420px); pointer-events: none; }
.map-title b { display: block; font: 600 20px/1.2 var(--display); color: var(--fg); }
.map-title span { display: block; font-size: 13px; color: var(--muted); margin-top: 2px; }
.app.presenting .map-title { display: block; }
.layers { flex-direction: column; align-items: stretch; gap: 3px; padding: 6px 12px 8px; max-width: none; }
.layers-title { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin-bottom: 2px; }
.layers label { font-size: 13px; color: var(--fg); gap: 7px; }
.proj-tag { cursor: pointer; }
.proj-tag:hover rect { filter: brightness(.92); }
.legend .l-proj { border-radius: 9px; width: 30px; background: var(--focus); color: #fff; }
.legend .l-op, .legend .l-vac, .legend .l-link { border-radius: 5px; }
.name-pill text { font-weight: 600; }
/* linea del tempo */
.tl { position: relative; margin-top: 8px; padding-left: 22px; }
.tl::before { content: ""; position: absolute; left: 6px; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.tl-item { position: relative; padding: 2px 0 16px; }
.tl-dot { position: absolute; left: -22px; top: 5px; width: 14px; height: 14px; border-radius: 50%; background: var(--panel); border: 2.5px solid var(--accent); box-sizing: border-box; }
.tl-item.now .tl-dot { border-color: var(--line-strong); border-style: dashed; }
.tl-item.now.dirty .tl-dot { border-color: var(--focus); background: var(--focus-soft); }
.tl-item.current .tl-dot { background: var(--accent); }
.tl-item.current .tl-body { background: var(--accent-soft); margin: 0 -8px; padding: 6px 8px; border-radius: 6px; }
.tl-when { font-size: 12px; color: var(--muted); font-weight: 600; letter-spacing: .02em; }
.tl-body { margin-top: 2px; font-size: 14px; }
/* procedura guidata */
.wizard { max-width: 620px; }
.wiz-steps { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin: 4px 0 14px; }
.wiz-steps .on { color: var(--accent); font-weight: 600; } .wiz-steps .done { color: var(--fg); }
.opt-list { display: grid; gap: 8px; margin-top: 8px; }
.opt-row { display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: start; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; cursor: pointer; margin: 0; font-size: 14px; color: var(--fg); }
.opt-row.on { border-color: var(--accent); background: var(--accent-soft); }
.opt-row input { margin: 3px 0 0; width: auto; }
@media (max-width: 800px) { .map-title b { font-size: 16px; } .map-title span { display: none; } .switch { display: none; } }

.layers-toggle { align-self: center; }
.layers { display: none; }
.layers.open { display: flex; }
@media (max-width: 800px) { .layers-toggle { display: none; } }

/* ---------- v0.5 ---------- */
.seg.mode button { padding: 4px 14px; }
.seg button:disabled { opacity: .5; cursor: default; }
.r-label.strong { font-weight: 600; font-size: 12px; }
.pdot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.layers label.sub { padding-left: 18px; font-size: 12px; color: var(--muted); }
.proj-legend { position: absolute; left: max(12px, env(safe-area-inset-left, 0px)); bottom: 12px; display: flex; flex-direction: column; gap: 2px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; box-shadow: var(--shadow); max-width: 260px; }
.proj-legend .pl-title { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); padding: 0 4px 2px; }
.pl-item { display: flex; align-items: center; gap: 8px; border: 0; background: none; padding: 3px 6px; border-radius: 6px; font: 13px var(--body); font-weight: 400; color: var(--fg); text-align: left; cursor: pointer; }
.pl-item i { width: 12px; height: 12px; border-radius: 50%; background: var(--pc); flex: none; }
.pl-item:hover, .pl-item.on { background: var(--accent-soft); }
.legend.on ~ .proj-legend, .proj-legend:has(+ .legend.on) { bottom: 12px; }
.legend.on { bottom: auto; top: 110px; }
.proj-band { pointer-events: none; }
.projects-view { position: absolute; inset: 0; overflow: auto; padding: 70px 16px 24px; }
.pv-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; align-items: start; }
.pv-col h3 { font: 600 12px var(--body); text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 0 0 8px; }
.pv-col.closed { opacity: .75; }
.pv-card { background: var(--panel); border: 1px solid var(--line); border-left: 5px solid var(--pc); border-radius: 8px; padding: 8px 10px; margin-bottom: 10px; cursor: pointer; display: grid; grid-template-columns: 70px 1fr; gap: 10px; }
.pv-card.on { outline: 2px solid var(--pc); }
.pv-card .mini { width: 70px; height: 70px; }
.pv-card p { font-size: 13px; margin: 4px 0; }
.pv-body { min-width: 0; font-size: 14px; }
@media (max-width: 800px) { .proj-legend { display: none; } .projects-view { padding-top: 60px; } }

.viewbox { z-index: 3; }
.projects-view { z-index: 1; }
.map-title { z-index: 2; }

.diffbox { margin-top: 8px; border-top: 1px dashed var(--line); padding-top: 6px; }
.diffbox select { width: auto; display: inline-block; padding: 1px 6px; font-size: 12px; margin-left: 4px; }
.pill { cursor: pointer; }

.map-title .filetag { display: inline-block; margin-top: 4px; font-size: 12px; color: var(--accent); background: var(--accent-soft); border-radius: 10px; padding: 1px 8px; }

.hold-row { grid-template-columns: 1fr auto; }
.rolelist li a { display: inline-flex; align-items: center; gap: 8px; }
.rolelist .ini { width: 22px; height: 22px; display: inline-grid; place-items: center; font-size: 9px; font-weight: 600; background: var(--accent-soft); color: var(--fg); }
.rolelist .ini.sq { border-radius: 6px; }
.rolelist .ri { width: 22px; height: 22px; padding: 3px; border-radius: 6px; background: var(--accent-soft); fill: none; stroke: var(--fg); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; box-sizing: border-box; }

/* ---------- modalità online: schermate di contorno ---------- */
.app.cloud-hidden { display: none; }
.cloud { min-height: 100%; background: var(--bg); color: var(--fg); overflow-y: auto; }
.cl-wrap { max-width: 520px; margin: 0 auto; padding: 18px max(16px, env(safe-area-inset-left, 0px)) 60px; }
.cl-wrap.wide { max-width: 860px; }
.cl-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 22px; }
.cl-brand { display: inline-flex; align-items: center; gap: 8px; font: 600 19px var(--display); color: var(--fg); text-decoration: none; }
.cl-brand svg { width: 26px; height: 26px; } .cl-brand circle { fill: var(--accent); } .cl-brand .m2 { opacity: .55; }
.cl-user { font-size: 13px; color: var(--muted); } .cl-user .go { color: var(--accent); cursor: pointer; }
.cl-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 22px 24px; }
.cl-card h1, .cl-org h1 { font: 600 24px var(--display); margin: 0 0 6px; }
.cl-card input[type=text], .cl-card input[type=email] { font-size: 16px; }
.cl-list { list-style: none; padding: 0; margin: 6px 0 0; display: grid; gap: 6px; }
.cl-list li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); font-size: 14px; flex-wrap: wrap; }
.cl-list li code { font-size: 12px; word-break: break-all; }
.cl-list a.go { color: var(--accent); text-decoration: none; font-weight: 600; }
.cl-orghead { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.cl-orghead select { width: auto; }
.cl-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin: 14px 0 16px; }
.cl-tabs a { padding: 8px 12px; color: var(--muted); text-decoration: none; font-weight: 600; font-size: 14px; border-bottom: 2px solid transparent; }
.cl-tabs a.on { color: var(--fg); border-bottom-color: var(--accent); }
.cl-maps { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.cl-map { display: grid; gap: 4px; align-content: start; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px; text-decoration: none; color: var(--fg); min-height: 84px; font: inherit; text-align: left; cursor: pointer; }
.cl-map:hover { border-color: var(--accent); } .cl-map b { font: 600 16px var(--display); }
.cl-map.new { border-style: dashed; color: var(--accent); font-weight: 600; align-content: center; justify-items: center; }
.cl-org h3 { font: 600 11px var(--body); text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 18px 0 6px; }
.status { font-size: 12px; color: var(--muted); cursor: pointer; }
.cloud .go { color: var(--accent); cursor: pointer; }
.cloud .warn { background: var(--focus-soft); border-radius: 6px; padding: 8px 10px; font-size: 14px; }

/* ---------- v0.8: comandi sulla mappa, menu utente, cambio mappa ---------- */
.brand { color: inherit; text-decoration: none; }
.viewbar { position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); z-index: 3; }
.seg.mode button { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px 4px 10px; }
.seg.mode button svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.zoom button.icon { width: 32px; height: 32px; padding: 5px; }
.zoom button.icon svg { width: 18px; height: 18px; }
.zoom .sep { height: 6px; }
@media (max-width: 800px) { .viewbox .seg.mode { display: none; } .viewbar .seg button { padding: 4px 9px; font-size: 12px; } .viewbar { bottom: 10px; left: 10px; transform: none; } .zoom #btnFit { display: none; } }
.map-title .filetag { pointer-events: auto; }
.map-title select.filetag { appearance: auto; -webkit-appearance: menulist; font: 600 12px var(--body); border: 0; cursor: pointer; padding: 1px 4px 1px 8px; max-width: 260px; }
.user-slot:empty { display: none; }
.user-chip { width: 32px; height: 32px; border-radius: 50%; padding: 0; display: inline-grid; place-items: center; font: 600 12px var(--body); background: var(--accent); color: var(--accent-ink); border: 0; cursor: pointer; letter-spacing: .02em; }
.user-menu { position: absolute; right: max(12px, env(safe-area-inset-right, 0px)); top: 50px; z-index: 30; min-width: 230px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); padding: 8px 0; }
.user-menu .um-who { padding: 6px 14px 8px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.user-menu .um-who b { display: block; }
.user-menu .um-who span { font-size: 12px; color: var(--muted); }
.user-menu a, .user-menu button.um { display: block; width: 100%; text-align: left; padding: 7px 14px; font: 14px var(--body); color: var(--fg); background: none; border: 0; border-radius: 0; cursor: pointer; text-decoration: none; }
.user-menu a:hover, .user-menu button.um:hover { background: var(--accent-soft); }
.user-menu form { padding: 6px 14px; display: flex; gap: 6px; }
.user-menu form input { flex: 1; }
@media (max-width: 800px) { .app { grid-template-columns: minmax(0, 1fr); } .top { overflow: hidden; } #draftPill { display: none; } }

/* "Mostra" accanto alle viste, in basso: il riquadro degli strati si apre verso l'alto */
.viewbar { display: flex; align-items: center; gap: 8px; }
.viewbar .layers { position: absolute; bottom: calc(100% + 8px); right: 0; min-width: 240px; }

/* stato del salvataggio e della cronologia, sotto Consulta/Modifica */
.editline { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); padding-right: 4px; }
.editline .pill { cursor: pointer; }
.editline .pill:hover { text-decoration: underline; }
@media (max-width: 800px) { .editline { display: none; } }
