:root {
  --bg: #f5f6f8; --panel: #ffffff; --panel-2: #f9fafb; --ink: #15202b; --ink-2: #334155; --muted: #64748b; --line: #e3e7ee; --line-2: #eef1f5;
  --accent: #1f4e8c; --accent-2: #17407a; --accent-soft: #e8f0fb; --on-accent: #ffffff; --ring: rgba(31, 78, 140, .28);
  --ok: #15803d; --ok-soft: #e6f6ec; --warn: #a15c00; --warn-soft: #fdf1e0; --bad: #b42318; --bad-soft: #fdecea;
  --att: #b45309; --att-soft: #fff5ea; --att-line: #f0d6b8;
  --star: #b7791f; --star-soft: #fbf3e0; --ini: #6d4bb3; --ini-soft: #f1ecfa; --fid: #0e7490; --fid-soft: #e3f4f8;
  --lk: #2f6fdb; --lk-soft: #e7effc; --avv: #8a2a5b; --avv-soft: #fbe8f1; --note: #fbf3c8; --note-line: #e8d78a; --xc: #fde9d9; --xc-ink: #9a3412;
  --radius: 12px; --radius-sm: 8px; --shadow: 0 1px 2px rgba(16,24,40,.04), 0 1px 3px rgba(16,24,40,.06);
  --shadow-lg: 0 12px 32px rgba(16,24,40,.16), 0 2px 6px rgba(16,24,40,.08);
  --ctl-h: 34px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Inter, Roboto, sans-serif;
  color: var(--ink); background: var(--bg); font-size: 14px; line-height: 1.45;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; color-scheme: light;
}
/* tema scuro: automatico (sistema) o scelto nel menu Strumenti */
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg:#0f1317; --panel:#171c22; --panel-2:#1c2229; --ink:#e7eaee; --ink-2:#c3c9d2; --muted:#98a2ad; --line:#2a323c; --line-2:#222930;
  --accent:#8db4e8; --accent-2:#a6c5ef; --accent-soft:#1d2c40; --on-accent:#0f1620; --ring: rgba(141,180,232,.35);
  --ok:#5cc58e; --ok-soft:#173226; --warn:#f0b35c; --warn-soft:#3a2a12; --bad:#f28b82; --bad-soft:#3b1b19;
  --att:#f0b35c; --att-soft:#2e2112; --att-line:#4a3418;
  --star:#e3b341; --star-soft:#3a2f14; --ini:#b9a1f0; --ini-soft:#2a2340; --fid:#5ec4d8; --fid-soft:#123038;
  --lk:#7fa8f0; --lk-soft:#1c2a42; --avv:#e79ac0; --avv-soft:#3a1a2b; --note:#3a3420; --note-line:#6b5d2a; --xc:#3b2416; --xc-ink:#fdba74;
  --shadow: 0 1px 2px rgba(0,0,0,.3); --shadow-lg: 0 12px 32px rgba(0,0,0,.5); color-scheme: dark; } }
:root[data-theme="dark"] {
  --bg:#0f1317; --panel:#171c22; --panel-2:#1c2229; --ink:#e7eaee; --ink-2:#c3c9d2; --muted:#98a2ad; --line:#2a323c; --line-2:#222930;
  --accent:#8db4e8; --accent-2:#a6c5ef; --accent-soft:#1d2c40; --on-accent:#0f1620; --ring: rgba(141,180,232,.35);
  --ok:#5cc58e; --ok-soft:#173226; --warn:#f0b35c; --warn-soft:#3a2a12; --bad:#f28b82; --bad-soft:#3b1b19;
  --att:#f0b35c; --att-soft:#2e2112; --att-line:#4a3418;
  --star:#e3b341; --star-soft:#3a2f14; --ini:#b9a1f0; --ini-soft:#2a2340; --fid:#5ec4d8; --fid-soft:#123038;
  --lk:#7fa8f0; --lk-soft:#1c2a42; --avv:#e79ac0; --avv-soft:#3a1a2b; --note:#3a3420; --note-line:#6b5d2a; --xc:#3b2416; --xc-ink:#fdba74;
  --shadow: 0 1px 2px rgba(0,0,0,.3); --shadow-lg: 0 12px 32px rgba(0,0,0,.5); color-scheme: dark; }
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
::selection { background: var(--accent-soft); }
* { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; } *::-webkit-scrollbar-thumb { background: var(--line); border-radius: 9px; border: 2px solid transparent; background-clip: padding-box; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }

/* ---------- barra superiore: menu minimo ---------- */
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 18px; height: 54px;
          padding: 0 20px; background: color-mix(in srgb, var(--panel) 86%, transparent); -webkit-backdrop-filter: saturate(160%) blur(12px); backdrop-filter: saturate(160%) blur(12px);
          border-bottom: 1px solid var(--line); }
@supports not (background: color-mix(in srgb, red 50%, blue)) { .topbar { background: var(--panel); } }
.brand { display: inline-flex; align-items: center; gap: 9px; font-weight: 700; font-size: 15.5px; letter-spacing: .01em; color: var(--ink); text-decoration: none; }
.brand::before { content: ""; width: 24px; height: 24px; border-radius: 7px; background: linear-gradient(135deg, var(--accent) 0%, #4f8fd6 100%);
                 box-shadow: inset 0 0 0 1px rgba(255,255,255,.12), 0 1px 2px rgba(16,24,40,.2); }
.nav { display: flex; gap: 2px; }
.nav a { text-decoration: none; color: var(--muted); padding: 7px 12px; border-radius: var(--radius-sm); font-weight: 500; transition: background .12s, color .12s; }
.nav a:hover { background: var(--line-2); color: var(--ink); }
.nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.topright { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.tools { position: relative; }
.menu { position: absolute; right: 0; top: 40px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
        box-shadow: var(--shadow-lg); min-width: 230px; padding: 6px; display: flex; flex-direction: column; animation: pop .14s ease-out; transform-origin: top right; }
.menu.hidden { display: none; }
/* schermi bassi: il menu scorre invece di finire sotto il bordo, e «Esci» resta sempre in vista */
.menu { max-height: calc(100vh - 56px); overflow-y: auto; overscroll-behavior: contain; }
.menu #logout { position: sticky; bottom: -6px; background: var(--panel); box-shadow: 0 -6px 10px -8px rgba(0,0,0,.35); }
.menu a { text-decoration: none; color: var(--ink); padding: 8px 10px; border-radius: var(--radius-sm); font-size: 13.5px; }
.menu a:hover, .menu a.active { background: var(--accent-soft); color: var(--accent); }
.menu .sep { height: 1px; background: var(--line); margin: 5px 4px; }
.menu .theme { display: flex; align-items: center; gap: 6px; padding: 6px 10px; font-size: 12.5px; color: var(--muted); }
.menu .theme button { padding: 2px 9px; font-size: 12px; min-height: 26px; border-radius: 999px; }
.menu .theme button.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
@keyframes pop { from { opacity: 0; transform: scale(.96) translateY(-4px); } to { opacity: 1; transform: none; } }

main { max-width: 1240px; margin: 0 auto; padding: 22px 26px 70px; min-width: 0; }
h1 { font-size: 22px; font-weight: 700; letter-spacing: -.01em; margin: 0 0 16px; line-height: 1.25; }
h2 { font-size: 15px; font-weight: 650; margin: 22px 0 10px; }
h3 { font-size: 11.5px; margin: 16px 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-bottom: 8px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); }
.tile b { font-size: 26px; display: block; font-variant-numeric: tabular-nums; letter-spacing: -.02em; line-height: 1.15; }
.tile span { color: var(--muted); font-size: 12px; }
button.tile { text-align: left; font-weight: 400; display: block; width: 100%; min-height: 0; cursor: pointer; }
button.tile:hover { border-color: var(--accent); box-shadow: var(--shadow-lg); transform: translateY(-1px); }
.tile .tilefoot { display: block; margin-top: 4px; font-size: 11px; }
.tile .tilefoot a { color: var(--muted); }
.tile .tilefoot a:hover { color: var(--accent); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; align-items: center; }
input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 6px 10px; min-height: var(--ctl-h);
                          transition: border-color .12s, box-shadow .12s; }
input[type=checkbox], input[type=radio] { min-height: 0; accent-color: var(--accent); }
select { padding-right: 28px; -webkit-appearance: none; appearance: none;
         background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'><path d='M6 9l6 6 6-6'/></svg>");
         background-repeat: no-repeat; background-position: right 9px center; }
textarea { width: 100%; min-height: 64px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .8; }
button { border: 1px solid var(--line); background: var(--panel); border-radius: var(--radius-sm); padding: 6px 12px; min-height: var(--ctl-h); cursor: pointer;
         font-weight: 500; transition: background .12s, border-color .12s, color .12s, box-shadow .12s, transform .06s; }
button:hover { border-color: var(--accent); background: var(--panel-2); }
button:active { transform: translateY(1px); }
button:disabled { opacity: .5; cursor: default; transform: none; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); box-shadow: 0 1px 2px rgba(16,24,40,.18); }
button.primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
button.link { border: none; background: none; padding: 0; min-height: 0; color: var(--accent); cursor: pointer; text-align: left; font-weight: 500; border-radius: 3px; }
button.link:hover { text-decoration: underline; text-underline-offset: 2px; background: none; }
button.icon { border: none; background: none; font-size: 22px; line-height: 1; padding: 4px 8px; display: inline-flex; align-items: center; color: var(--muted); }
button.icon:hover { color: var(--ink); background: var(--line-2); border-radius: var(--radius-sm); }
button.ghost { background: transparent; }
button.danger { color: var(--bad); }
button.danger:not(.link):hover { border-color: var(--bad); background: var(--bad-soft); }
button.star { color: var(--star); }
button.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
button.on.star { background: var(--star-soft); border-color: var(--star); color: var(--star); }
table { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
thead tr:first-child th:first-child, tbody:first-child tr:first-child td:first-child { border-top-left-radius: calc(var(--radius) - 1px); }
thead tr:first-child th:last-child, tbody:first-child tr:first-child td:last-child { border-top-right-radius: calc(var(--radius) - 1px); }
tr:last-child td:first-child { border-bottom-left-radius: calc(var(--radius) - 1px); } tr:last-child td:last-child { border-bottom-right-radius: calc(var(--radius) - 1px); }
tr:last-child td { border-bottom: none; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
th { font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; background: var(--panel-2); border-bottom: 1px solid var(--line); }
thead th { position: sticky; top: 54px; z-index: 1; }
tbody tr:hover > td { background: var(--panel-2); }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--accent-soft); }
tr.dim td { opacity: .55; }
td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.act { white-space: nowrap; }
td.act button { padding: 2px 8px; font-size: 12px; min-height: 26px; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 500; line-height: 1.5; background: var(--panel-2); border: 1px solid var(--line); white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.pill.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.pill.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.pill.acc { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.pill.star { background: var(--star-soft); color: var(--star); border-color: transparent; }
.score { font-weight: 700; font-variant-numeric: tabular-nums; }
.list { display: flex; flex-direction: column; gap: 6px; }
.item { padding: 9px 11px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--panel); cursor: pointer; transition: border-color .12s, box-shadow .12s; }
.item:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.empty { color: var(--muted); padding: 18px; text-align: center; border: 1px dashed var(--line); border-radius: var(--radius); }
.drawer { position: fixed; inset: 0; z-index: 20; }
.drawer.hidden { display: none; }
.drawer-bg { position: absolute; inset: 0; background: rgba(10,14,20,.38); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); animation: fade .16s ease-out; }
.drawer-panel { position: absolute; right: 0; top: 0; bottom: 0; width: min(1180px, 100%); background: var(--bg);
                overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
                padding: 0 24px calc(60px + env(safe-area-inset-bottom)); box-shadow: -8px 0 32px rgba(0,0,0,.18); animation: slidein .2s cubic-bezier(.2,.8,.2,1); }
@keyframes slidein { from { transform: translateX(24px); opacity: .6; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.drawer-panel thead th { top: 0; }
#drawer-body { padding-top: 20px; }
html.drawer-open, html.drawer-open body { overflow: hidden; }       /* la pagina sotto la scheda non scorre */
/* chiusura sempre visibile, anche a scheda scorsa; area di tocco ampia */
.drawer button.icon.close, .drawer button.icon.close:hover { position: fixed; right: max(10px, env(safe-area-inset-right)); top: max(8px, env(safe-area-inset-top)); z-index: 8;
                 width: 40px; height: 40px; padding: 0; border-radius: 50%; font-size: 22px; line-height: 1;
                 background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow-lg); }
/* intestazione della scheda: resta in alto mentre scorri */
.dhead { position: -webkit-sticky; position: sticky; top: 0; z-index: 6; background: var(--bg);
         margin: -20px -24px 0; padding: 20px 64px 6px 24px; }
.dhead.stuck { padding-top: 10px; padding-bottom: 8px; background: color-mix(in srgb, var(--panel) 92%, transparent); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
               border-bottom: 1px solid var(--line); box-shadow: 0 4px 12px rgba(16,24,40,.08); }
.dhead.stuck h1 { font-size: 17px; }
.dhead.stuck .dpills .pill.albo, .dhead.stuck .dpills .pill.ini { display: none; }
.dhead .dsub { display: none; color: var(--muted); margin-top: 3px; align-items: center; gap: 4px 12px; flex-wrap: wrap; }
.dhead.stuck .dsub { display: flex; }
.dhead .dsub [data-top] { margin-left: auto; }
/* accanto al nome: famiglia, legami professionali, relazioni (un clic porta alla sezione) */
.dnav { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-left: 12px; }
.dnav-x { background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px;
          font-size: 12px; min-height: 0; color: var(--ink-2); white-space: nowrap; }
.dnav-x:hover { border-color: var(--accent); color: var(--accent); }
.dnav-x b { color: var(--accent); }
.dnav-x.zero { color: var(--muted); opacity: .75; }
@media (max-width: 860px) { .dnav { margin-left: 0; } }
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; }
.form label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); }
.form label.full { grid-column: 1 / -1; }
.form input, .form select, .form textarea { color: var(--ink); font-size: 14px; }
.timeline { display: flex; flex-direction: column; gap: 8px; }
.tl { border-left: 3px solid var(--line); padding: 4px 0 4px 10px; }
.tl.positivo { border-color: var(--ok); } .tl.negativo { border-color: var(--bad); } .tl.richiamare { border-color: var(--warn); }
.outcomes { display: flex; gap: 6px; flex-wrap: wrap; }
.outcomes button.sel { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.quick { display: flex; gap: 6px; flex-wrap: wrap; }
.queue { display: grid; grid-template-columns: 300px 1fr; gap: 18px; }
.queue .list { max-height: calc(100vh - 200px); overflow-y: auto; }
.item.current { border-color: var(--accent); background: var(--accent-soft); }
.big { font-size: 20px; font-weight: 700; }
.tel { font-size: 18px; font-weight: 600; text-decoration: none; }
.kanban { display: grid; grid-template-columns: repeat(5, minmax(180px, 1fr)); gap: 12px; }
.col { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; min-height: 200px; }
.col h3 { margin-top: 0; }
.toast { position: fixed; bottom: max(20px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg);
         padding: 9px 16px; border-radius: 10px; z-index: 40; box-shadow: var(--shadow-lg); max-width: min(92vw, 560px); animation: toastin .18s ease-out; font-weight: 500; }
@keyframes toastin { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }
.toast.hidden { display: none; }
.truncate { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar { display: grid; grid-template-columns: 120px 1fr 36px; gap: 8px; align-items: center; margin: 5px 0; }
.bar .track { background: var(--bg); border-radius: 3px; height: 10px; overflow: hidden; }
.bar .track i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.bar b { text-align: right; font-variant-numeric: tabular-nums; }
.fs { grid-column: 1 / -1; border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px 10px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; margin: 4px 0 0; }
.fs legend { font-size: 12px; font-weight: 600; color: var(--ink); padding: 0 4px; }
.fs label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); }
.fs label.full { grid-column: 1 / -1; }
/* report componibile */
.sections { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px; }
.sections label { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); cursor: pointer; }
.sections label.on { border-color: var(--accent); background: var(--accent-soft); }
.sections label input { margin-top: 3px; }
.sections b { display: block; font-size: 13px; }
.sections span { font-size: 12px; color: var(--muted); }
.watchbox { border-left: 3px solid var(--star); }
.watchbox.excl { border-left-color: var(--bad); }
@media (max-width: 900px) {
  .topbar { gap: 10px; padding: 0 12px; } .nav a { padding: 7px 8px; }
  .grid2, .grid3, .queue { grid-template-columns: 1fr; } main { padding: 16px 12px; } .kanban { grid-template-columns: 1fr; }
}

pre.log { background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; font-size: 11px; max-height: 220px; overflow: auto; white-space: pre-wrap; margin: 0; }
.hidden { display: none !important; }
.empty.small { padding: 8px; text-align: left; }
tr, .item { scroll-margin-top: 110px; }

/* smistamento contatti da valutare */
button.okb { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
button.badb { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
tr.todo td:first-child { box-shadow: inset 3px 0 0 var(--star); }
.scopo { color: var(--ink); max-width: 520px; white-space: normal; margin-top: 2px; }

/* flusso contatti */
.flow { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 4px; }
.flow button { border-radius: 999px; padding: 5px 12px; }
.flow button .n { color: var(--muted); font-variant-numeric: tabular-nums; margin-left: 2px; }
.flow button.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.flow button.on .n { color: var(--on-accent); opacity: .8; }
.flowhelp { margin: 4px 0 10px; min-height: 16px; }
.bulkbar { position: sticky; top: 62px; z-index: 5; margin-bottom: 10px; border-color: var(--accent); }
.sep-v { width: 1px; height: 22px; background: var(--line); display: inline-block; }
.pill.ini { background: var(--ini-soft); color: var(--ini); border-color: transparent; }
.chip { border-radius: 999px; padding: 2px 10px; font-size: 12px; }
.chip.on { background: var(--ini-soft); border-color: var(--ini); color: var(--ini); font-weight: 600; }
.ctab .scopo { max-width: 560px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink); opacity: .85; }
/* ricerca globale */
.gsearch { position: relative; flex: 1; max-width: 420px; margin-left: 12px; }
.gsearch input { width: 100%; padding: 6px 12px 6px 34px; border-radius: 999px; background: var(--line-2); border-color: transparent;
                 background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.2' stroke-linecap='round'><circle cx='11' cy='11' r='7'/><path d='M20 20l-3.5-3.5'/></svg>"); background-repeat: no-repeat; background-position: 12px center; }
.gsearch input:focus { background-color: var(--panel); border-color: var(--accent); }
.gsres { position: absolute; top: 40px; left: 0; right: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
         box-shadow: var(--shadow-lg); max-height: 70vh; overflow-y: auto; z-index: 30; animation: pop .14s ease-out; transform-origin: top center; }
.gsh { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 8px 12px 4px; }
.gsi { padding: 7px 12px; cursor: pointer; border-top: 1px solid var(--line); }
.gsi:hover { background: var(--accent-soft); }
@media (max-width: 900px) { .gsearch { max-width: 260px; margin-left: 4px; } }
@media (max-width: 640px) { .gsearch { display: none; } }

/* ---------- iPad e schermi touch: aree di tocco ampie, niente zoom automatico sui campi ---------- */
html { -webkit-text-size-adjust: 100%; touch-action: manipulation; }   /* niente ritardo del tocco, niente doppio-tocco-zoom */
@media (pointer: coarse) {
  button:not(.link):not(.pill):not(.icon), select, input[type=text], input[type=search], input[type=email], input[type=tel], input[type=date], input[type=datetime-local], input[type=number] { min-height: 40px; }
  input, select, textarea { font-size: 16px; }                     /* Safari iPad ingrandisce la pagina sui campi sotto i 16px */
  .form input, .form select, .form textarea { font-size: 16px; }
  button.link { padding: 3px 2px; }
  .nav a { padding: 10px 12px; }
  .outcomes button, .quick button, .chip { min-height: 38px; }
  input[type=checkbox], input[type=radio] { width: 20px; height: 20px; }
  .menu a { padding: 12px 12px; }
  .gsi { padding: 11px 12px; }
  .gsearch input { min-height: 38px; }
  .proc button { min-height: 34px; padding: 4px 10px; }
  .drawer-panel { padding-left: 20px; padding-right: 20px; }
  .dhead { margin-left: -20px; margin-right: -20px; padding-left: 20px; }
  .ghelp { font-size: 13px; }
  .gtools button, .gtools label { min-height: 40px; }
}

/* classifica e opportunità */
.spark { display: flex; align-items: flex-end; gap: 2px; height: 28px; margin: 4px 0; }
.spark i { display: block; flex: 1; min-width: 3px; background: var(--accent); border-radius: 2px 2px 0 0; opacity: .8; }
.spark.tall { height: 70px; }
.up { color: var(--ok); font-weight: 600; } .down { color: var(--bad); font-weight: 600; }
.item.opp.late { border-color: var(--bad); }
.form label .hint { font-size: 11px; color: var(--muted); font-weight: 400; }

ul.why { margin: 4px 0 0; padding-left: 18px; } ul.why li { margin: 2px 0; }
h2.row { margin: 22px 0 10px; }

/* Oggi: pianificazione selezionabile */
.item.plan { display: grid; grid-template-columns: 22px 1fr; gap: 6px; align-items: start; }
.item.plan > input { margin-top: 3px; }
.item.plan.sel { border-color: var(--accent); background: var(--accent-soft); }
.dayhead { display: flex; justify-content: space-between; align-items: center; margin: 8px 2px 2px; font-size: 12px; font-weight: 600; text-transform: capitalize; }
.dayhead:first-child { margin-top: 0; }
h2 select { font-size: 13px; padding: 2px 6px; margin-left: 4px; }
.link.qname { padding: 0; text-align: left; color: var(--ink); text-decoration: none; }
.link.qname:hover { color: var(--accent); text-decoration: underline; }
/* compagine societaria */
table.offt { font-size: 13px; }
table.offt td, table.offt th { vertical-align: top; }
table.offt input, table.offt select { font-size: 12px; padding: 3px 5px; width: 100%; }
table.offt td:first-child input[type=checkbox] { width: auto; }
tr.dim td { opacity: .55; }
.nowrap { white-space: nowrap; }
.catgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.catgrid .card .row { padding: 1px 0; flex-wrap: nowrap; gap: 6px; }
.catgrid .card .row > span:last-child { white-space: nowrap; flex: none; font-variant-numeric: tabular-nums; }
.catgrid .card .row > span:first-child { min-width: 0; }
.catgrid [data-catmenu], .catgrid [data-secmenu] { opacity: .55; } .catgrid [data-catmenu]:hover, .catgrid [data-secmenu]:hover { opacity: 1; }
/* soggetti a rischio */
.pill.black { background: #1f1f1f; color: #fff; border-color: #1f1f1f; font-weight: 600; }
.pill.texas { background: #8a3b12; color: #fff; border-color: #8a3b12; font-weight: 600; }
.riskbox { border-left: 3px solid #1f1f1f; background: rgba(31,31,31,.05); }
.okbox { background: var(--ok-soft); color: var(--ok); border-radius: var(--radius-sm); padding: 6px 9px; }

/* ---------- fiduciario: mandati e fiduciarie (per i soggetti fa fede l'albo cantonale) ---------- */
.pill.fid { background: var(--fid-soft); color: var(--fid); border-color: transparent; }
.fidbox { border-left: 3px solid var(--fid); }
/* foto della scheda: tonda, non deforma l'immagine (ritaglio al centro) */
.ava { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; vertical-align: middle; margin-right: 6px;
       border: 1px solid var(--line); background: var(--panel-2); }
.ava-lg { width: 46px; height: 46px; }
.ava-sm { width: 24px; height: 24px; margin-right: 5px; }
.ava-xs { width: 19px; height: 19px; margin-right: 4px; border-width: 0; vertical-align: -4px; }
.ava-ini { display: inline-flex; align-items: center; justify-content: center; color: var(--muted); font-size: 14px; font-weight: 700; }
.ava-sm.ava-ini { font-size: 10px; }
.avabtn { background: none; border: 0; padding: 0; cursor: pointer; line-height: 0; }
.phowrap .phobox { background: var(--panel); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow-lg); text-align: center; }
.phowrap .phobox img { max-width: min(86vw, 560px); max-height: 70vh; border-radius: 10px; display: block; margin: 0 auto; }
.phowrap .phoname { margin-top: 8px; }
.avabtn:hover .ava { border-color: var(--accent); }

/* fiduciaria di cui la persona fa parte: pastiglia accanto al nome, uguale ovunque la persona compaia */
.pill.fidof { background: var(--fid-soft); color: var(--fid); border: 1px dashed var(--fid); font-weight: 600; white-space: normal; }
.fidof-line { display: block; margin: 2px 0 1px; font-weight: 400; }
/* fiduciaria di cui la persona fa parte: si legge accanto al nome, nella compagine e nelle proposte di domicilio */
.fidline { color: var(--fid); margin: 2px 0; }
.fidline .link { color: inherit; font-weight: 600; }
tr.mandate td { background: var(--fid-soft); }
tr.mandate td:first-child { border-left: 3px solid var(--fid); }
/* stesso cognome nella compagine: una barra a sinistra unisce le persone, come una parentesi */
.compt tr.famg td:first-child { position: relative; padding-left: 16px; }
.compt tr.famg td:first-child::before { content: ""; position: absolute; left: 4px; top: 0; bottom: 0; width: 3px;
                                        background: var(--ini); }
.famg-lab { color: var(--ini); font-weight: 600; font-size: 10.5px; letter-spacing: .02em; display: block; margin: 1px 0 2px; }
.compt tr.famg-top td:first-child::before { top: 12px; border-radius: 3px 3px 0 0; }
.compt tr.famg-end td:first-child::before { bottom: 12px; border-radius: 0 0 3px 3px; }

/* cognome in maiuscolo (solo a video) */
.sn { text-transform: uppercase; letter-spacing: .01em; }
table.offt td, table.offt th { text-align: left; }
table.offt td:first-child > button.link:first-child { display: block; width: 100%; text-align: left; }
.pname-fields { grid-column: 1 / -1; }
tr.inlineform > td { background: var(--bg); padding: 8px; }
tr.inlineform #offform { margin: 0; }
table.offt tr.inlineform input[type=radio], table.offt tr.inlineform input[type=checkbox] { width: auto; }
table.offt tr.inlineform input:not([type=radio]):not([type=checkbox]), table.offt tr.inlineform select { font-size: 13px; padding: 5px 7px; }
/* riga aggiornata da una modifica: breve evidenza */
@keyframes flashrow { from { background: var(--flash, rgba(255, 214, 102, .45)); } to { background: transparent; } }
tr.flash > td { animation: flashrow 1.2s ease-out; }
@media (prefers-reduced-motion: reduce) { tr.flash > td { animation: none; } }
/* albo cantonale dei fiduciari */
.pill.albo { background: var(--fid-soft); color: var(--fid); border: 1px solid var(--fid); font-weight: 600; }
.pill.albo.unsure { border-style: dashed; opacity: .8; font-weight: 500; }
.pill.avv { background: var(--avv-soft); color: var(--avv); border: 1px solid var(--avv); font-weight: 600; }
.pill.avv.unsure { border-style: dashed; opacity: .8; font-weight: 500; }
/* indirizzo nell'intestazione della scheda */
.addr { margin: -6px 0 10px; }
.chip.on button.link { margin-left: 4px; padding: 0 2px; text-decoration: none; }
/* compagine: le azioni (modifica · fiduciario · togli) stanno sotto il nome, sempre visibili; le etichette vanno a capo */
table.offt .offact { margin-top: 4px; }
table.offt .offact button.link { padding: 0; }
table.compt .pill { white-space: normal; }
table.compt td:nth-child(4) { overflow-wrap: anywhere; }
/* finestre di conferma nella pagina */
.askwrap { position: fixed; inset: 0; z-index: 1000; background: rgba(10, 14, 20, .42); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); display: grid; place-items: center; padding: 16px; animation: fade .14s ease-out; }
.askbox { width: min(460px, 100%); max-height: 80vh; overflow: auto; box-shadow: var(--shadow-lg); animation: pop .16s ease-out; }
.askmsg { white-space: normal; line-height: 1.45; }
.askin { width: 100%; margin-top: 10px; }
.askbox button.askdanger { background: var(--bad); color: #fff; border-color: var(--bad); }
/* doppioni: confronto affiancato */
table.dupcmp th { width: 130px; white-space: nowrap; color: var(--muted); font-weight: 500; }
table.dupcmp td { min-width: 220px; }
table.dupcmp input[type=radio] { width: auto; }
/* compagine: altre società della persona, come sottocartelle */
.otreehead { margin-top: 4px; color: var(--ini); font-weight: 600; }
ul.otree { list-style: none; margin: 2px 0 2px 4px; padding: 0 0 0 12px; border-left: 2px solid var(--ini-soft); }
ul.otree li { position: relative; padding: 1px 0; line-height: 1.4; }
ul.otree li::before { content: ""; position: absolute; left: -12px; top: .75em; width: 9px; border-top: 2px solid var(--ini-soft); }
ul.otree li.dim { opacity: .6; }
ul.otree button.link { padding: 0; text-align: left; }
/* link con l'aspetto di un pulsante (es. «Cerca le sue società nel Registro») */
a.btnlink { display: inline-flex; align-items: center; border: 1px solid var(--line); background: var(--panel); border-radius: var(--radius-sm); padding: 6px 12px; min-height: var(--ctl-h); color: inherit; text-decoration: none; font-weight: 500; }
a.btnlink:hover { border-color: var(--accent); }
/* quadratino del Registro di commercio prima del nome di una società */
.rcdot { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 6px; vertical-align: 1px; flex: none; }
.rcdot.ok { background: var(--ok); }
.rcdot.old { background: #d4a017; }
.rcdot.no { background: var(--bad); }
h1 .rcdot { width: 12px; height: 12px; vertical-align: 3px; }

/* ---------- mappa delle relazioni ---------- */
.gwrap { position: fixed; inset: 0; z-index: 15; background: var(--bg); display: flex; flex-direction: column; }
.gbar { display: flex; align-items: center; gap: 8px; padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.gtools { margin-left: auto; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.gtools label { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: var(--muted); }
.ghelp { padding: 6px 16px; display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }
.glegend { display: inline-flex; gap: 6px; align-items: center; margin-left: auto; }
.glegend .lg { display: inline-block; width: 12px; height: 12px; margin-left: 6px; vertical-align: -2px; }
.lg.sq { border: 2px solid var(--accent); border-radius: 3px; background: var(--panel); }
.lg.ci { border: 2px solid var(--ini); border-radius: 50%; background: var(--panel); }
.lg.dash { width: 18px; height: 0; border-top: 2px dashed var(--muted); }
.lg.dot { width: 18px; height: 0; border-top: 2px dotted var(--fid); }
.glegend .rcdot { margin-right: 0; }
.gstage { position: relative; flex: 1; min-height: 0; }
.gsvg { width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; user-select: none; }
.gsvg:active { cursor: grabbing; }
.gedge { stroke: var(--muted); stroke-width: 1.4; opacity: .7; }
.gedge.relazione { stroke: var(--accent); stroke-width: 2; }
.gedge.referente { stroke: var(--ini); }
.gedge.old { stroke-dasharray: 6 4; opacity: .35; }
.gedge.mand { stroke: var(--fid); stroke-dasharray: 2 3; opacity: .55; }
.glab { font-size: 9.5px; fill: var(--muted); text-anchor: middle; paint-order: stroke; stroke: var(--bg); stroke-width: 3px; pointer-events: none; }
.glab.old { opacity: .5; }
.gnode { cursor: pointer; }
.gnode .gshape { fill: var(--panel); stroke: var(--accent); stroke-width: 2.2; }
.gnode.persona .gshape { stroke: var(--ini); }
.gnode.contatto .gshape { stroke: var(--ini); stroke-dasharray: 3 2; }
.gnode .gshape.gone { stroke: var(--bad); }
.gnode.center .gshape { stroke-width: 4; }
.gnode.sel .gshape { fill: var(--accent-soft); }
.gnode .gdot.ok { fill: var(--ok); } .gnode .gdot.old { fill: #d4a017; } .gnode .gdot.no { fill: var(--bad); }
.gnode .gname { font-size: 11px; fill: var(--ink); text-anchor: middle; paint-order: stroke; stroke: var(--bg); stroke-width: 3.5px; }
.gnode.center .gname { font-weight: 700; font-size: 12.5px; }
.gmore circle { fill: var(--accent); }
.gmore text { fill: #fff; font-size: 8.5px; font-weight: 700; text-anchor: middle; }
.ginfo { position: absolute; right: 14px; top: 14px; width: min(340px, calc(100% - 28px)); background: var(--panel); border: 1px solid var(--line);
         border-radius: var(--radius); box-shadow: 0 8px 24px rgba(16,24,40,.14); padding: 12px; }
.ginfo.hidden { display: none; }
.garrow { fill: var(--accent); }

/* ---------- note della scheda: sfondo giallo paglierino ---------- */
.card.notebox, textarea.notebox { background: var(--note); border-color: var(--note-line); }
.notebox.pnote { background: var(--note); border: 1px solid var(--note-line); border-radius: 6px; padding: 3px 7px; margin: 3px 0; max-width: 420px; }

/* ---------- legami di famiglia ---------- */
.famline { color: var(--ini); margin: 2px 0; }
.gedge.famiglia { stroke: var(--ini); stroke-width: 2.4; opacity: .85; }
.lg.fam { width: 18px; height: 0; border-top: 3px solid var(--ini); }

/* ---------- relazioni: gruppi ordinati, separati dalla compagine ---------- */
.relgroup { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px; margin-bottom: 8px; }
.relhead { margin-bottom: 4px; }
.relhead .n { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--accent-soft); color: var(--accent);
              font-size: 11.5px; font-weight: 600; text-align: center; margin-left: 4px; }
.relfilter { width: 180px; padding: 4px 8px; font-size: 12.5px; }
table.relt { margin: 0; }
table.relt td { padding: 5px 6px; vertical-align: middle; }
table.relt tr.hidden { display: none; }
table.relt { table-layout: fixed; width: 100%; }
table.relt td:nth-child(1) { width: 44%; } table.relt td:nth-child(2) { width: 32%; } table.relt td:nth-child(3) { width: 15%; } table.relt td:nth-child(4) { width: 9%; }
table.relt td { overflow: hidden; text-overflow: ellipsis; }

/* ---------- legami professionali ---------- */
.proline { color: var(--accent); margin: 2px 0; }
.gedge.professionale { stroke: var(--accent); stroke-width: 2; stroke-dasharray: 8 3; opacity: .85; }
.lg.pro { width: 18px; height: 0; border-top: 2px dashed var(--accent); }
.pill.xc { background: var(--xc); color: var(--xc-ink); border-color: transparent; font-weight: 600; }
/* elenco contatti su iPad: l'oggetto sociale va a capo invece di allargare la tabella oltre lo schermo */
@media (max-width: 1300px) {
  .ctab .scopo { max-width: none; white-space: normal; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
}
@media (max-width: 900px) {                                          /* iPad verticale: la regione lascia spazio al nome */
  .ctab th:nth-child(4), .ctab td:nth-child(4) { display: none; }
}

/* ---------- rete linked: chi conosco e le società raggiungibili tramite loro ---------- */
.lkico { fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; vertical-align: -2px; }
.pill.lk { background: var(--lk-soft); color: var(--lk); border-color: transparent; display: inline-flex; align-items: center; gap: 3px; font-weight: 600; }
.pill.lk.mini { padding: 0 4px; }
.netic { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; border-radius: 50%; vertical-align: -4px; margin-left: 2px; }
.netic.l1 { background: var(--lk); color: var(--on-accent); }
.netic.l2 { background: transparent; color: var(--lk); border: 1.5px dashed var(--lk); opacity: .8; }
.netic .lkico { width: 12px; height: 12px; vertical-align: 0; }
.netbox { border-left: 3px solid var(--lk); }
.netbox.l2 { border-left-style: dashed; }
.netbox > b .lkico { color: var(--lk); }
.netpath { margin-top: 5px; line-height: 1.7; }
button.lkon { background: var(--lk-soft); border-color: var(--lk); color: var(--lk); font-weight: 600; }
button[data-linktog] .lkico { vertical-align: -2px; }
.gnode .glk { fill: none; stroke: var(--lk); stroke-width: 2.5; stroke-dasharray: none; }
.glegend .lg.lkr { display: inline-block; width: 12px; height: 12px; border-radius: 50%; border: 2.5px solid var(--lk); vertical-align: -2px; }
/* collegamenti da verificare */
.netic.l3 { background: transparent; color: var(--lk); border: 1.5px dotted var(--lk); font-weight: 700; font-size: 11px; opacity: .75; }
.netic.lp { background: transparent; color: var(--muted); border: 1.5px dotted var(--muted); font-weight: 700; font-size: 11px; }
.netbox.l3 { border-left-style: dotted; }
.netbox.lp { border-left-style: dotted; border-left-color: var(--muted); }
details.reach summary { cursor: pointer; list-style: none; }
details.reach summary::-webkit-details-marker { display: none; }
details.reach summary::after { content: " ▸"; color: var(--muted); }
details.reach[open] summary::after { content: " ▾"; }
.forse { color: var(--warn); font-style: italic; }
.matchbox { border-left: 3px solid var(--warn); margin-bottom: 8px; }
.mrow { padding: 8px 0; }
.mrow + .mrow { border-top: 1px solid var(--line); }
.mpair { display: grid; grid-template-columns: 1fr 28px 1fr; gap: 8px; align-items: start; margin: 6px 0 2px; }
.meq { text-align: center; font-size: 18px; color: var(--muted); padding-top: 2px; }
@media (max-width: 640px) { .mpair { grid-template-columns: 1fr; } .meq { text-align: left; } }
.gsmaybe { margin-top: 4px; padding: 4px 6px; border-radius: 6px; background: var(--warn-soft); display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }
.gsmaybe .gsact { margin-left: auto; display: inline-flex; gap: 6px; align-items: center; }
.gsmaybe .gsact button { padding: 2px 10px; }
/* suggerimenti sotto i campi (sostituiscono la tendina <datalist> del browser) */
.sugg { position: absolute; z-index: 40; background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
        box-shadow: 0 8px 24px rgba(16,24,40,.16); max-height: 300px; overflow-y: auto; }
.sugg.hidden { display: none; }
.sgi { padding: 8px 10px; cursor: pointer; font-size: 13.5px; color: var(--ink); border-top: 1px solid var(--line); }
.sgi:first-child { border-top: 0; }
.sgi.on, .sgi:hover { background: var(--accent-soft); }
@media (pointer: coarse) { .sgi { padding: 12px; font-size: 15px; } }

/* area Backup */
.bkdisk { margin: 0 0 10px; }
.bkbar { position: relative; height: 8px; border-radius: 4px; background: var(--line-2); overflow: hidden; margin-bottom: 4px; }
.bkbar span { position: absolute; left: 0; top: 0; bottom: 0; background: var(--line); }
.bkbar span.bk { background: var(--accent); }
.bkt td, .bkt th { vertical-align: top; }
.small.bad { color: var(--bad); }

/* ---------- scheda a due colonne: a sinistra struttura e legami (registro, compagine, ruoli, famiglia, relazioni, annunci),
   a destra il lavoro quotidiano (iniziative, note, referenti, attività, storico, opportunità) ---------- */
.dgrid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 0 22px; align-items: start; }
.dgrid .dmain { grid-column: 1; grid-row: 1; min-width: 0; }
.dgrid .dmain2 { grid-column: 1; grid-row: 2; min-width: 0; }
.dgrid .dside { grid-column: 2; grid-row: 1 / span 2; min-width: 0; border-left: 1px solid var(--line); padding-left: 22px; }
.dgrid .dside > h3:first-child, .dgrid .dmain > h3:first-child { margin-top: 0; }
.legami { border-left: 3px solid var(--ini); padding-left: 10px; margin: 6px 0 10px; }
.legami > h3:first-child { margin-top: 6px; }
.ownco .proline { color: var(--accent); }
@media (max-width: 1000px) {
  .dgrid { grid-template-columns: 1fr; }
  .dgrid .dmain { grid-row: auto; order: 1; } .dgrid .dmain2 { grid-row: auto; order: 2; }
  .dgrid .dside { grid-column: 1; grid-row: auto; order: 3; border-left: 0; padding-left: 0; border-top: 1px solid var(--line); padding-top: 10px; margin-top: 10px; }
}

/* altri numeri e provenienza nella scheda */
.phbox { margin: 6px 0 2px; }
.phitem { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); }
.phitem .tel { font-size: 13px; font-weight: 500; }
.orgbox { margin: 6px 0 10px; gap: 6px; }
.orgbox .chip { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; border: 1px solid var(--line); background: var(--panel); }
.orgbox .chip.on { background: var(--xc); border-color: var(--xc-ink); color: var(--xc-ink); font-weight: 600; }
.orgbox .chip input { margin: 0; }

/* bandierina della residenza estera (dall'attinenza del registro) */
.flag { font-size: 15px; line-height: 1; vertical-align: -1px; margin-left: 3px; cursor: help;
        font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif; }
h1 .flag { font-size: 18px; }

/* fonte del dato nelle righe della compagine */
.pill.src { background: var(--panel-2); color: var(--muted); border-color: var(--line); font-weight: 500; }
.pill.xc.mini, .pill.src { font-size: 11px; padding: 0 7px; margin-right: 4px; }
button.link.mini { font-size: 11.5px; color: var(--muted); }
button.link.mini:hover { color: var(--accent); }

/* schema del percorso nella rete: chi conosci → passaggi → questa scheda */
.netmap { display: flex; align-items: center; flex-wrap: wrap; gap: 2px 0; margin: 6px 0 4px; }
.nmnode { display: inline-flex; align-items: center; gap: 6px; max-width: 230px; padding: 5px 11px; border: 1px solid var(--line);
          border-radius: 999px; background: var(--panel); font-size: 12.5px; font-weight: 500; color: var(--ink);
          white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-height: 0; }
button.nmnode { cursor: pointer; }
button.nmnode:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.nmnode.known { border-color: var(--lk); background: var(--lk-soft); color: var(--lk); font-weight: 600; }
.nmnode.self { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nmdot { width: 9px; height: 9px; border-radius: 50%; background: var(--ini); flex: none; }
.nmdot.co { border-radius: 2px; background: var(--accent); }
.nmnode.known .nmdot { background: var(--lk); }
.nmedge { position: relative; display: inline-flex; align-items: center; justify-content: center; min-width: 74px; height: 26px; margin: 0 1px; }
.nmedge::before { content: ""; position: absolute; left: 2px; right: 10px; top: 50%; height: 1.5px; background: var(--line); }
.nmedge::after { content: ""; position: absolute; right: 2px; top: 50%; width: 7px; height: 7px; border-top: 1.5px solid var(--line);
                 border-right: 1.5px solid var(--line); transform: translateY(-50%) rotate(45deg); }
.nmedge .nmrel { position: relative; z-index: 1; padding: 0 5px; background: var(--bg); font-size: 10.5px; color: var(--muted);
                 max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .nmedge .nmrel { background: var(--panel); }
.nmedge.forse::before, .nmedge.forse::after { border-color: var(--warn); background: transparent; }
.nmedge.forse::before { background: repeating-linear-gradient(90deg, var(--warn) 0 4px, transparent 4px 8px); height: 1.5px; }
.nmedge.forse .nmrel { color: var(--warn); font-style: italic; }
.netstep + .netstep { margin-top: 10px; border-top: 1px dashed var(--line); padding-top: 8px; }
.netstep .netpath { opacity: .75; }
@media (pointer: coarse) { .nmnode { min-height: 32px; } }

/* intestazione fissa della scheda: nome, indirizzo e chi ti porta al contatto restano sempre visibili */
.dhead .dsub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dhead .dsub .dsub-addr { color: var(--ink-2); }
.dhead .dsub .tel { font-size: 13px; font-weight: 500; }
button.pill.lk.dsub-known { cursor: pointer; display: inline-flex; align-items: center; gap: 3px; min-height: 0; padding: 1px 9px; }
button.pill.lk.dsub-known:hover { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
@media (max-width: 760px) { .dhead .dsub .dsub-addr { display: none; } }

/* ---------- report della scheda (pronto da stampare o salvare in PDF) ---------- */
#report { position: fixed; inset: 0; z-index: 60; background: var(--bg); overflow: auto; }
.rp-bar { position: sticky; top: 0; display: flex; align-items: center; gap: 14px; justify-content: space-between;
          padding: 10px 18px; background: var(--panel); border-bottom: 1px solid var(--line); z-index: 2; }
.rp-page { max-width: 820px; margin: 18px auto 40px; background: #fff; color: #111; padding: 26px 30px;
           border-radius: var(--radius); box-shadow: var(--shadow-lg); font-size: 12.5px; line-height: 1.45; }
.rp-head { display: flex; gap: 16px; align-items: flex-start; border-bottom: 2px solid #111; padding-bottom: 12px; }
.rp-head .rp-foto { width: 74px; height: 74px; border-radius: 10px; object-fit: cover; border: 1px solid #ddd; margin: 0; }
.rp-head .ava-ini.rp-foto { display: inline-flex; align-items: center; justify-content: center; font-size: 24px; color: #777; background: #f1f3f6; }
.rp-id { flex: 1; min-width: 0; }
.rp-id h1 { font-size: 21px; margin: 0 0 3px; color: #111; letter-spacing: -.01em; }
.rp-sub { color: #555; }
.rp-tags { margin-top: 5px; display: flex; flex-wrap: wrap; gap: 5px; }
.rp-tag { border: 1px solid #bbb; border-radius: 999px; padding: 0 8px; font-size: 10.5px; color: #333; }
.rp-when { text-align: right; color: #666; font-size: 10.5px; white-space: nowrap; }
.rp-grid { columns: 2; column-gap: 26px; margin-top: 14px; }
.rp-sec { break-inside: avoid; margin: 0 0 14px; display: inline-block; width: 100%; }
.rp-sec h2 { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #666; margin: 0 0 5px;
             border-bottom: 1px solid #e3e3e3; padding-bottom: 3px; }
.rp-kv th { text-align: left; font-weight: 600; color: #555; width: 38%; vertical-align: top; padding: 1px 8px 1px 0; }
.rp-kv td { vertical-align: top; padding: 1px 0; }
.rp-t { width: 100%; border-collapse: collapse; }
.rp-t th { text-align: left; font-size: 10px; text-transform: uppercase; color: #777; border-bottom: 1px solid #e3e3e3; padding: 2px 6px 2px 0; }
.rp-t td { vertical-align: top; padding: 3px 6px 3px 0; border-bottom: 1px solid #f0f0f0; }
.rp-note { color: #666; font-size: 10.5px; }
.rp-rel { color: #555; font-style: italic; }
.rp-rel-g { margin-bottom: 6px; }
.rp-rel-h { font-weight: 600; }
.rp-more { color: #777; font-size: 10.5px; font-style: italic; }
.rp-scopo { color: #333; margin-top: 4px; }
.rp-chain { margin: 2px 0; }
.rp-foot { margin-top: 16px; border-top: 1px solid #e3e3e3; padding-top: 6px; color: #777; font-size: 10px; }
@media print {
  body > *:not(#report) { display: none !important; }
  #report { position: static; overflow: visible; background: #fff; }
  .rp-bar { display: none !important; }
  .rp-page { box-shadow: none; margin: 0; max-width: none; padding: 0; border-radius: 0; }
  @page { size: A4; margin: 13mm; }
}

/* dati pubblicati sul web: una riga per dato, con la fonte e la spunta */
.webbox { border-left: 3px solid var(--accent); }
.weblist { display: flex; flex-direction: column; gap: 2px; }
.webrow { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; padding: 4px 6px; border-radius: var(--radius-sm); cursor: pointer; }
.webrow:hover { background: rgba(0,0,0,.035); }
.webrow.uguale { opacity: .55; }
.webrow .wlab { color: #666; min-width: 72px; }
.webrow .wval { word-break: break-all; }
.webrow input { margin: 0; }

/* il logo trovato sul sito, in anteprima nella riga da spuntare */
.weblogo { max-height: 34px; max-width: 150px; object-fit: contain; vertical-align: middle; background: #fff; border-radius: 3px; padding: 2px; }

/* riquadro delle attività in cima alla scheda */
.attbox { margin: 0 0 12px; border: 1px solid var(--att-line); border-left: 4px solid var(--att); padding: 12px 14px;
           background: var(--att-soft); }
.attbox.late { border-left-color: var(--bad); }
/* registrazione con tutti i campi: chiusa, dentro la stessa sezione */
.attbox details.attmore { margin-top: 10px; }
.attbox details.attmore > summary { cursor: pointer; font-size: 13px; color: var(--att); }
.attbox .attform { margin-top: 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
/* storico dentro la sezione: scorre da sé quando è lungo */
.attbox .attstorico { margin-top: 10px; border-top: 1px solid var(--att-line); padding-top: 8px; }
.attbox .timeline { margin-top: 6px; max-height: 320px; overflow: auto; padding-right: 4px; }
.attbox .tl { border-left-width: 3px; }
.attbox .empty { background: transparent; border: 0; }
.attrow { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) auto auto; gap: 16px; align-items: start; }
.attcell { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.attlab { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.attcell.attn { text-align: center; }
.attcell.attdo { flex-direction: row; gap: 6px; align-items: center; }
.attcell .danger { color: var(--bad); }
.attcell .accent { color: var(--accent); }
@media (max-width: 900px) { .attrow { grid-template-columns: 1fr 1fr; } .attcell.attdo { grid-column: 1 / -1; } }
/* diario: le scadute si vedono subito */
.afplan tr.late td { background: rgba(185, 28, 28, .05); }
.tile.click { cursor: pointer; }
.tile.click:hover { border-color: var(--accent); }

/* archivio delle attività fatte: chiuso, si apre quando serve */
details.arch > summary { cursor: pointer; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
details.arch > summary:hover { border-color: var(--accent); }
details.arch > summary span { margin-left: 8px; }
details.arch[open] > summary { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }

/* ---------------------------------------------------------------- iniziative */
.inigrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.inicard { display: flex; flex-direction: column; gap: 8px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
           padding: 14px 16px; box-shadow: var(--shadow); color: var(--ink); text-decoration: none; transition: border-color .12s, transform .12s; }
.inicard:hover { border-color: var(--accent); }
.inicard.closed { opacity: .72; }
.inicard .ininame { font-size: 15px; line-height: 1.3; }
.iniroles { display: flex; flex-direction: column; gap: 3px; font-size: 13px; }
.inifoot { display: flex; flex-wrap: wrap; gap: 4px 12px; border-top: 1px solid var(--line-2); padding-top: 7px; margin-top: auto; }
.rolelab { display: inline-block; min-width: 86px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
/* un colore per ruolo: si riconoscono a colpo d'occhio, nell'elenco e nella pagina */
.r-cliente { --rc: #1f6fb2; } .r-controparte { --rc: #b45309; } .r-segnalatore { --rc: #7c3aed; }
.r-partner { --rc: #0f766e; } .r-consulente { --rc: #be185d; } .r-nd { --rc: var(--muted); }
:root[data-theme="dark"] .r-cliente { --rc: #7fb3e6; } :root[data-theme="dark"] .r-controparte { --rc: #f0a35c; }
:root[data-theme="dark"] .r-segnalatore { --rc: #b79cf5; } :root[data-theme="dark"] .r-partner { --rc: #5fc7b9; } :root[data-theme="dark"] .r-consulente { --rc: #f08cbd; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .r-cliente { --rc: #7fb3e6; } :root:not([data-theme="light"]) .r-controparte { --rc: #f0a35c; }
  :root:not([data-theme="light"]) .r-segnalatore { --rc: #b79cf5; } :root:not([data-theme="light"]) .r-partner { --rc: #5fc7b9; } :root:not([data-theme="light"]) .r-consulente { --rc: #f08cbd; } }
.rolelab[class*="r-"] { color: var(--rc); }
.rolegrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
.rolecol { background: var(--panel); border: 1px solid var(--line); border-top: 3px solid var(--rc); border-radius: var(--radius); padding: 10px; display: flex; flex-direction: column; gap: 8px; min-height: 90px; }
.rolehead { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--rc); }
.rolenone { padding: 4px 0; }
.actor { display: flex; gap: 8px; align-items: flex-start; padding: 6px; border-radius: var(--radius-sm); background: var(--panel-2); }
.actor .ava { width: 34px; height: 34px; font-size: 12px; flex: none; }
.actor-body { min-width: 0; flex: 1; }
.actor-body > .link { text-align: left; }
.actor-tools { display: flex; align-items: center; gap: 6px; margin-top: 4px; }
.actor-tools select { width: auto; min-height: 0 !important; padding: 2px 6px; font-size: 12px; }
.addactor { margin-top: 10px; }
.legami { margin-top: 10px; }
.legami ul { margin: 6px 0 0; padding-left: 18px; }
.legami li { margin: 3px 0; }
.legami .rel { color: var(--muted); font-style: italic; margin: 0 4px; }
.phases { display: flex; flex-wrap: wrap; gap: 6px; }
.phases button { border-radius: 999px; font-size: 12.5px; }
.phases button.on { font-weight: 700; }
.phases button.ph-acc { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.phases button.ph-warn { background: var(--warn-soft); color: var(--warn); border-color: var(--warn); }
.phases button.ph-bad { background: var(--bad-soft); color: var(--bad); border-color: var(--bad); }
.phases button.ph-ok { background: var(--ok-soft); color: var(--ok); border-color: var(--ok); }
.phases button.ph-nd { background: var(--panel-2); color: var(--ink); border-color: var(--ink-2); }
.inidesc { margin-top: 12px; }
.inidesc textarea { width: 100%; margin-top: 6px; resize: vertical; }
a.pill.inilink { text-decoration: none; }
a.pill.inilink:hover { text-decoration: underline; }
.chip a.inilink { color: inherit; }
/* allegati */
.atts { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 6px; }
.att { position: relative; display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--panel); }
.att > a { display: inline-flex; align-items: center; gap: 6px; padding: 3px 8px; text-decoration: none; color: var(--ink); font-size: 12px; max-width: 280px; }
.att .an { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att.img > a { padding: 2px; }
.att.img img { width: 64px; height: 64px; object-fit: cover; border-radius: 4px; display: block; }
.att .attx { position: absolute; top: -8px; right: -8px; background: var(--panel); border: 1px solid var(--line); border-radius: 999px;
             width: 18px; height: 18px; line-height: 14px; padding: 0; font-size: 13px; display: none; }
.att:hover .attx, .att:focus-within .attx { display: block; }
@media (hover: none) { .att .attx { display: block; } }
.ext { display: inline-block; font-size: 10px; font-weight: 700; letter-spacing: .03em; padding: 1px 4px; border-radius: 3px; background: var(--accent-soft); color: var(--accent); }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-bottom: 12px; }
.gallery a { display: flex; flex-direction: column; gap: 4px; text-decoration: none; color: var(--muted); font-size: 11.5px; }
.gallery img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: var(--radius-sm); border: 1px solid var(--line); }
table.docs td { vertical-align: middle; }
@media (max-width: 640px) {
  .inigrid { grid-template-columns: 1fr; }
  .rolegrid { grid-template-columns: 1fr 1fr; }
  .rolecol:not(.vuota) { grid-column: 1 / -1; }
  .rolecol.vuota { min-height: 0; padding: 6px 10px; }
  .rolecol.vuota .rolenone { display: none; }
  .att > a { max-width: 200px; }
}
.tscroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
@media (max-width: 440px) { .nav a { padding: 7px 7px; } .topbar .brand { font-size: 0; gap: 0; } .nav { gap: 0; } }
.timeline .tl { overflow-wrap: anywhere; min-width: 0; }
