/* Carattere Atkinson Hyperlegible Next (Braille Institute, licenza SIL OFL 1.1), incluso per funzionare anche offline. */
@font-face { font-family: "Atkinson Hyperlegible Next"; font-style: normal; font-weight: 200 800; font-display: swap; src: url(../fonts/atkinson-next-latin.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Atkinson Hyperlegible Next"; font-style: normal; font-weight: 200 800; font-display: swap; src: url(../fonts/atkinson-next-latin-ext.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }

/* Poros — interfaccia.
   Principi: un'azione principale per schermata, testo grande e contrastato, etichette in italiano semplice,
   colore mai da solo (sempre accompagnato da testo), bordi al posto delle ombre, aree cliccabili ampie. */

:root {
  --font: "Atkinson Hyperlegible Next", "Segoe UI", system-ui, sans-serif;
  --ink: #16191d;
  --ink-2: #454b53;
  --ink-3: #626973;
  --line: #d7dbe0;
  --line-2: #e9ecef;
  --bg: #f2f4f5;
  --surface: #ffffff;
  --surface-2: #f7f8f9;
  --brand: #0b5d5e;
  --brand-strong: #074546;
  --brand-soft: #e2efee;
  --brand-ink: #063b3c;
  --p-alta: #0b5d5e;
  --p-media: #4a8f8d;
  --p-bassa: #a4c9c7;
  --p-minima: #d5dddd;
  --danger: #b42318;
  --danger-soft: #fdeceb;
  --warn: #8a5300;
  --warn-soft: #fff3dc;
  --ok: #1a7140;
  --ok-soft: #e4f3e9;
  --focus: #f0a400;
  --radius: 8px;
  --radius-lg: 12px;
  --header-h: 64px;
}

* { box-sizing: border-box; }
html { font-size: 16px; }
html, body { margin: 0; }
body { font-family: var(--font); color: var(--ink); background: var(--bg); line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--brand); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--brand-strong); }
h1, h2, h3, h4 { line-height: 1.25; margin: 0; }
h1 { font-size: 1.75rem; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 1.2rem; font-weight: 700; }
h3 { font-size: 1rem; font-weight: 700; }
p { margin: 0 0 .75rem; }
.hidden { display: none !important; }
.muted { color: var(--ink-3); }
.small { font-size: .875rem; }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; text-align: right; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.icon { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -4px; }
.icon.sm { width: 16px; height: 16px; vertical-align: -3px; }

/* --- Accesso --- */
#login { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: var(--brand-strong); }
.login-box { background: var(--surface); border-radius: var(--radius-lg); padding: 36px 32px; width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 18px; }
.login-box h1 { font-size: 1.5rem; }

/* --- Testata e navigazione --- */
.logo { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.25rem; color: var(--ink); text-decoration: none; letter-spacing: -.01em; }
.logo svg { width: 30px; height: 30px; }
#header { position: sticky; top: 0; z-index: 50; background: var(--surface); border-bottom: 1px solid var(--line); }
.header-in { max-width: 1320px; margin: 0 auto; height: var(--header-h); display: flex; align-items: center; gap: 28px; padding: 0 24px; }
#nav { display: flex; gap: 4px; height: 100%; }
#nav a { display: flex; align-items: center; gap: 8px; padding: 0 12px; color: var(--ink-2); text-decoration: none; font-weight: 600; border-bottom: 3px solid transparent; border-top: 3px solid transparent; }
#nav a:hover { color: var(--ink); background: var(--surface-2); }
#nav a.active { color: var(--brand-strong); border-bottom-color: var(--brand); }
.header-tools { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.search { position: relative; }
.search input { width: 260px; padding-left: 38px; }
.search .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--ink-3); pointer-events: none; }
.menu { position: relative; }
.menu-list { position: absolute; right: 0; top: calc(100% + 6px); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); min-width: 230px; padding: 6px; z-index: 60; box-shadow: 0 8px 24px rgba(16, 24, 32, .12); }
.menu-list a, .menu-list button { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 10px 12px; border: 0; background: none; border-radius: 6px; color: var(--ink); text-decoration: none; font: inherit; cursor: pointer; }
.menu-list a:hover, .menu-list button:hover { background: var(--surface-2); }
.menu-list .sep { height: 1px; background: var(--line-2); margin: 6px 0; }
.menu-list .who { padding: 8px 12px; font-size: .875rem; color: var(--ink-3); }
#bottomNav { display: none; }

main#main { max-width: 1320px; margin: 0 auto; padding: 28px 24px 80px; }

/* --- Intestazione pagina --- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head p { margin: 6px 0 0; color: var(--ink-2); max-width: 70ch; }
.crumb { font-size: .875rem; margin-bottom: 6px; }
.crumb a { color: var(--ink-3); }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* --- Bottoni --- */
.btn { font: inherit; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 8px 16px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--surface-2); border-color: #c3c8ce; color: var(--ink); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-strong); border-color: var(--brand-strong); color: #fff; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--brand-strong); }
.btn-ghost:hover { background: var(--brand-soft); border-color: transparent; color: var(--brand-ink); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); color: var(--danger); border-color: #f1b8b3; }
.btn-sm { min-height: 34px; padding: 4px 12px; font-size: .9rem; }
.btn-icon { min-height: 40px; width: 40px; padding: 0; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
button.link { border: 0; background: none; padding: 0; color: var(--brand); font: inherit; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

/* --- Campi --- */
input, select, textarea { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid #b9bfc6; border-radius: var(--radius); padding: 9px 12px; min-height: 42px; min-width: 0; width: 100%; }
textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: 3px solid var(--brand-soft); border-color: var(--brand); }
input[type=checkbox], input[type=radio] { width: 20px; height: 20px; min-height: 0; accent-color: var(--brand); margin: 0; flex: none; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .field > .label { font-weight: 600; font-size: .95rem; }
.field .help { font-size: .85rem; color: var(--ink-3); }
.req { color: var(--danger); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 18px; }
.form-grid .full { grid-column: 1 / -1; }
fieldset { border: 0; padding: 0; margin: 0 0 26px; }
legend { font-weight: 700; font-size: 1rem; padding: 0 0 10px; color: var(--brand-strong); width: 100%; border-bottom: 1px solid var(--line-2); margin-bottom: 14px; }
.check { display: flex; align-items: center; gap: 10px; min-height: 42px; cursor: pointer; }
.form-error { background: var(--danger-soft); color: var(--danger); border-radius: var(--radius); padding: 10px 14px; font-weight: 600; }

/* Scala a pulsanti (1-5) */
.scale { display: grid; grid-template-columns: repeat(5, 1fr); border: 1px solid #b9bfc6; border-radius: var(--radius); overflow: hidden; }
.scale label { position: relative; text-align: center; padding: 8px 4px; cursor: pointer; font-size: .85rem; line-height: 1.2; border-left: 1px solid var(--line); background: var(--surface); }
.scale label:first-child { border-left: 0; }
.scale input { position: absolute; opacity: 0; pointer-events: none; }
.scale label b { display: block; font-size: 1rem; }
.scale label:has(input:checked) { background: var(--brand); color: #fff; }
.scale label:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: -3px; }

/* Scelte multiple a chip */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-opt { display: inline-flex; align-items: center; gap: 8px; border: 1px solid #b9bfc6; border-radius: 99px; padding: 7px 14px; cursor: pointer; font-size: .92rem; background: var(--surface); }
.chip-opt input { width: 16px; height: 16px; }
.chip-opt:has(input:checked) { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-ink); font-weight: 600; }
.chip-group-title { width: 100%; font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); margin-top: 6px; }

/* --- Contenitori --- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 22px; }
.card + .card { margin-top: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head p { margin: 4px 0 0; color: var(--ink-3); font-size: .9rem; }
.grid { display: grid; gap: 18px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.layout-side { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 22px; align-items: start; }
.stack > * + * { margin-top: 18px; }

/* Numeri chiave */
.figures { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); margin-bottom: 22px; }
.figure { padding: 16px 20px; border-left: 1px solid var(--line-2); text-decoration: none; color: inherit; display: block; }
.figure:first-child { border-left: 0; }
a.figure:hover { background: var(--surface-2); color: inherit; }
.figure .v { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; }
.figure .l { color: var(--ink-2); font-size: .92rem; }
.figure .s { font-size: .85rem; color: var(--ink-3); }

/* --- Priorità --- */
.prio { display: inline-flex; align-items: center; gap: 10px; white-space: nowrap; }
.prio .bar { width: 64px; height: 8px; border-radius: 99px; background: var(--line-2); overflow: hidden; }
.prio .bar i { display: block; height: 100%; border-radius: 99px; }
.prio .t { font-weight: 700; font-size: .92rem; min-width: 76px; }
.prio .t small { font-weight: 400; color: var(--ink-3); font-size: .85rem; margin-left: 4px; }
.lvl-alta { background: var(--p-alta); } .lvl-media { background: var(--p-media); } .lvl-bassa { background: var(--p-bassa); } .lvl-minima { background: var(--p-minima); }
.big-prio { display: flex; align-items: baseline; gap: 12px; }
.big-prio .n { font-size: 2.6rem; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.big-prio .w { font-size: 1.2rem; font-weight: 700; }
.meters { display: grid; gap: 14px; margin-top: 18px; }
.meter .row1 { display: flex; justify-content: space-between; gap: 8px; font-size: .95rem; }
.meter .row1 b { font-variant-numeric: tabular-nums; }
.meter .track { height: 10px; border-radius: 99px; background: var(--line-2); margin-top: 6px; overflow: hidden; }
.meter .track i { display: block; height: 100%; background: var(--brand); border-radius: 99px; }
.meter .hint { font-size: .82rem; color: var(--ink-3); margin-top: 3px; }
.meter.nd .track i { background: transparent; }

/* --- Etichette --- */
.tag { display: inline-flex; align-items: center; gap: 6px; font-size: .82rem; font-weight: 600; padding: 3px 10px; border-radius: 99px; background: var(--line-2); color: var(--ink-2); white-space: nowrap; }
.tag.brand { background: var(--brand-soft); color: var(--brand-ink); }
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.danger { background: var(--danger-soft); color: var(--danger); }
.tag.outline { background: transparent; border: 1px solid var(--line); }
.due-late { color: var(--danger); font-weight: 700; }
.due-today { color: var(--warn); font-weight: 700; }

/* --- Righe di elenco --- */
.rows { list-style: none; margin: 0; padding: 0; }
.rows > li { display: flex; gap: 14px; align-items: flex-start; padding: 14px 0; border-top: 1px solid var(--line-2); }
.rows > li:first-child { border-top: 0; padding-top: 4px; }
.rows .main { flex: 1; min-width: 0; }
.rows .title { font-weight: 700; }
.rows .meta { color: var(--ink-3); font-size: .9rem; }
.rows .side { text-align: right; flex: none; }
.why { color: var(--ink-2); font-size: .92rem; margin-top: 4px; }

/* Opportunità da seguire (home) */
.lead { display: grid; grid-template-columns: minmax(0, 1fr) 210px; gap: 18px; padding: 18px 0; border-top: 1px solid var(--line-2); }
.lead:first-of-type { border-top: 0; padding-top: 4px; }
.lead h3 a { color: var(--ink); text-decoration: none; }
.lead h3 a:hover { text-decoration: underline; }
.lead .service { margin-top: 6px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.lead .next { border-left: 1px solid var(--line-2); padding-left: 18px; font-size: .92rem; }
.lead .next .lbl { color: var(--ink-3); font-size: .82rem; text-transform: uppercase; letter-spacing: .05em; }

/* --- Tabelle --- */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); }
table.data { width: 100%; border-collapse: collapse; }
table.data th, table.data td { padding: 13px 14px; border-bottom: 1px solid var(--line-2); text-align: left; vertical-align: top; }
table.data tr:last-child td { border-bottom: 0; }
table.data th { font-size: .85rem; color: var(--ink-2); font-weight: 700; background: var(--surface-2); white-space: nowrap; }
table.data th button { font: inherit; font-weight: 700; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; display: inline-flex; gap: 4px; align-items: center; }
table.data tbody tr:hover td { background: #fafbfb; }
table.data td.name a { font-weight: 700; color: var(--ink); text-decoration: none; }
table.data td.name a:hover { text-decoration: underline; color: var(--brand-strong); }
table.data .sub { color: var(--ink-3); font-size: .88rem; }
.pager { display: flex; gap: 10px; align-items: center; justify-content: space-between; padding: 12px 4px; color: var(--ink-2); }

/* --- Filtri --- */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px; }
.toolbar .field { min-width: 170px; }
.toolbar .grow { flex: 1; min-width: 240px; }
.more-filters { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 16px; margin-bottom: 14px; }
.active-filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.active-filters button.tag { border: 0; cursor: pointer; font: inherit; font-size: .85rem; font-weight: 600; }
.selbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; background: var(--brand-soft); border: 1px solid #b8d6d4; border-radius: var(--radius-lg); padding: 10px 14px; margin-bottom: 14px; }
.selbar select { width: auto; min-width: 200px; }

/* Segmentato (filtri rapidi, fasi) */
.segmented { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 3px; gap: 2px; flex-wrap: wrap; }
.segmented button { font: inherit; font-weight: 600; border: 0; background: none; border-radius: 6px; padding: 7px 14px; cursor: pointer; color: var(--ink-2); min-height: 36px; }
.segmented button[aria-pressed=true] { background: var(--brand); color: #fff; }
.segmented button .cnt { font-weight: 400; opacity: .85; margin-left: 4px; }

/* --- Schede (tab) --- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; }
.tabs button { font: inherit; font-weight: 600; border: 0; background: none; padding: 12px 16px; color: var(--ink-2); border-bottom: 3px solid transparent; margin-bottom: -1px; cursor: pointer; white-space: nowrap; }
.tabs button[aria-selected=true] { color: var(--brand-strong); border-bottom-color: var(--brand); }
.tabs .cnt { display: inline-block; min-width: 22px; padding: 0 6px; border-radius: 99px; background: var(--line-2); font-size: .8rem; margin-left: 6px; color: var(--ink-2); }

/* --- Avanzamento fasi --- */
.journey { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 14px; }
.journey .step { border-top: 5px solid var(--line-2); padding-top: 8px; font-size: .88rem; color: var(--ink-3); }
.journey .step.done { border-top-color: var(--p-bassa); color: var(--ink-2); }
.journey .step.now { border-top-color: var(--brand); color: var(--ink); font-weight: 700; }
.journey .step.closed-won { border-top-color: var(--ok); }
.journey .step.closed-lost { border-top-color: #a8adb3; }

/* --- Diario --- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 36px minmax(0, 1fr); gap: 12px; padding: 12px 0; border-top: 1px solid var(--line-2); }
.timeline li:first-child { border-top: 0; }
.timeline .dot { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-2); }
.timeline .dot.brand { background: var(--brand-soft); border-color: #b8d6d4; color: var(--brand-strong); }
.timeline .when { color: var(--ink-3); font-size: .86rem; }
.timeline .body { white-space: pre-wrap; color: var(--ink-2); margin-top: 4px; }
.todo { display: flex; gap: 12px; align-items: flex-start; }
.todo input { margin-top: 3px; }
.todo.done .title { text-decoration: line-through; color: var(--ink-3); }

/* --- Segnali --- */
.signal { padding: 16px 0; border-top: 1px solid var(--line-2); }
.signal:first-child { border-top: 0; padding-top: 0; }
.signal .head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; }
.signal .fact { font-size: 1.02rem; }
.signal .interp { color: var(--ink-2); margin-top: 6px; padding-left: 14px; border-left: 3px solid var(--p-bassa); }
.signal .foot { display: flex; flex-wrap: wrap; gap: 6px 16px; color: var(--ink-3); font-size: .87rem; margin-top: 8px; align-items: center; }
.dots { display: inline-flex; gap: 3px; vertical-align: middle; }
.dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.dots i.on { background: var(--brand); }

/* Catena logica dell'analisi */
.chain { display: grid; gap: 0; }
.chain .ring { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 16px; padding: 14px 0; border-top: 1px solid var(--line-2); }
.chain .ring:first-child { border-top: 0; }
.chain .ring > h4 { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--brand-strong); padding-top: 3px; }
.chain ul { margin: 0; padding-left: 18px; }
.chain li + li { margin-top: 6px; }

/* Servizi */
.svc { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 14px; padding: 14px 0; border-top: 1px solid var(--line-2); align-items: center; }
.svc:first-child { border-top: 0; padding-top: 0; }
.svc .reasons { grid-column: 1 / -1; margin: 0; padding-left: 18px; color: var(--ink-2); font-size: .9rem; }
.svc.weak { opacity: .6; }

/* Fattori */
.factor { display: grid; grid-template-columns: minmax(0, 1fr) 150px auto; gap: 6px 16px; padding: 12px 0; border-top: 1px solid var(--line-2); align-items: center; }
.factor .why { grid-column: 1 / -1; font-size: .87rem; color: var(--ink-3); }
.src { font-size: .75rem; font-weight: 700; padding: 2px 8px; border-radius: 99px; text-transform: uppercase; letter-spacing: .04em; }
.src.auto { background: var(--line-2); color: var(--ink-2); }
.src.manuale { background: var(--warn-soft); color: var(--warn); }
.src.ai { background: var(--brand-soft); color: var(--brand-ink); }
.src.nd { color: var(--ink-3); border: 1px dashed var(--line); }

/* --- Pipeline --- */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: 14px; overflow-x: auto; padding-bottom: 6px; align-items: start; }
.col { background: #e8ebed; border-radius: var(--radius-lg); padding: 10px; min-height: 160px; }
.col.over { outline: 3px dashed var(--brand); outline-offset: -3px; }
.col-head { display: flex; justify-content: space-between; align-items: baseline; padding: 4px 6px 10px; gap: 8px; }
.col-head h3 { font-size: .98rem; }
.col-head span { color: var(--ink-3); font-size: .85rem; }
.kcard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-bottom: 10px; cursor: grab; }
.kcard:active { cursor: grabbing; }
.kcard .t a { font-weight: 700; color: var(--ink); text-decoration: none; }
.kcard .t a:hover { text-decoration: underline; }
.kcard .m { font-size: .86rem; color: var(--ink-3); margin-top: 6px; display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.kcard .move { margin-top: 10px; }
.kcard .move select { min-height: 34px; padding: 4px 8px; font-size: .88rem; }

/* --- Matrice --- */
.matrix svg { width: 100%; height: auto; display: block; }
.matrix circle { cursor: pointer; stroke: #fff; stroke-width: 1.5; }
.matrix a:focus-visible circle, .matrix circle:hover { stroke: var(--ink); stroke-width: 2.5; }
.legend { display: flex; gap: 18px; flex-wrap: wrap; font-size: .88rem; color: var(--ink-2); margin-top: 10px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }

/* Barre orizzontali dei report */
.hbars { display: grid; gap: 10px; }
.hbar .row1 { display: flex; justify-content: space-between; gap: 10px; font-size: .92rem; }
.hbar .row1 span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar .row1 b { font-variant-numeric: tabular-nums; }
.hbar .track { height: 8px; background: var(--line-2); border-radius: 99px; margin-top: 4px; overflow: hidden; }
.hbar .track i { display: block; height: 100%; background: var(--p-media); border-radius: 99px; }

/* --- Pannello laterale (form) --- */
#drawer { position: fixed; inset: 0; z-index: 200; display: flex; justify-content: flex-end; background: rgba(16, 24, 32, .38); }
.drawer-box { background: var(--surface); width: 100%; max-width: 640px; height: 100%; display: flex; flex-direction: column; }
.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 22px 26px 16px; border-bottom: 1px solid var(--line); }
.drawer-head p { margin: 4px 0 0; color: var(--ink-3); font-size: .92rem; }
.drawer-body { flex: 1; overflow-y: auto; padding: 22px 26px; }
.drawer-foot { display: flex; justify-content: space-between; gap: 10px; padding: 16px 26px; border-top: 1px solid var(--line); background: var(--surface-2); }
.drawer-foot .actions { margin-left: auto; }

/* Dialogo di conferma */
#modal { position: fixed; inset: 0; z-index: 300; display: grid; place-items: center; padding: 16px; background: rgba(16, 24, 32, .45); }
.modal-box { background: var(--surface); border-radius: var(--radius-lg); max-width: 480px; width: 100%; padding: 24px; }
.modal-box p { margin: 10px 0 20px; color: var(--ink-2); }

/* Avvisi */
#toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: 24px; z-index: 400; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: var(--ink); color: #fff; padding: 12px 18px; border-radius: var(--radius); font-weight: 600; display: flex; gap: 10px; align-items: center; max-width: 92vw; }
.toast.err { background: var(--danger); }
.notice { display: flex; gap: 12px; padding: 14px 16px; border-radius: var(--radius); background: var(--brand-soft); color: var(--brand-ink); margin-bottom: 18px; }
.notice.warn { background: var(--warn-soft); color: var(--warn); }
.notice.danger { background: var(--danger-soft); color: var(--danger); }
.empty { text-align: center; padding: 34px 20px; color: var(--ink-2); }
.empty h3 { margin-bottom: 6px; }
.empty .actions { justify-content: center; margin-top: 14px; }
.loading { padding: 40px; text-align: center; color: var(--ink-3); }
.spin { display: inline-block; width: 18px; height: 18px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -3px; }
@keyframes spin { to { transform: rotate(360deg); } }
details > summary { cursor: pointer; font-weight: 600; color: var(--brand-strong); }
dl.facts { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 8px 16px; margin: 0; }
dl.facts dt { color: var(--ink-3); }
dl.facts dd { margin: 0; overflow-wrap: anywhere; }
.term { border-bottom: 1px dotted var(--ink-3); cursor: help; }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

@media (max-width: 1100px) {
  .layout-side { grid-template-columns: minmax(0, 1fr); }
  .search input { width: 200px; }
  #nav a span { display: none; }
}
@media (max-width: 760px) {
  html { font-size: 16px; }
  .header-in { padding: 0 16px; gap: 12px; }
  #nav { display: none; }
  .search { display: none; }
  #bottomNav { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; bottom: 0; left: 0; right: 0; z-index: 50; background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
  #bottomNav a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 2px; font-size: .74rem; font-weight: 600; color: var(--ink-3); text-decoration: none; }
  #bottomNav a.active { color: var(--brand-strong); }
  main#main { padding: 20px 16px 96px; }
  h1 { font-size: 1.45rem; }
  .g2, .g3, .form-grid { grid-template-columns: minmax(0, 1fr); }
  .figures { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .figure:nth-child(3) { border-left: 0; }
  .figure:nth-child(n+3) { border-top: 1px solid var(--line-2); }
  .lead { grid-template-columns: minmax(0, 1fr); }
  .lead .next { border-left: 0; padding-left: 0; }
  .chain .ring { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .factor { grid-template-columns: minmax(0, 1fr) auto; }
  .factor .prio, .factor > .meter { grid-column: 1 / -1; }
  dl.facts { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  dl.facts dd { margin-bottom: 8px; }
  .toolbar .field { min-width: 0; flex: 1 1 140px; }
  .drawer-head, .drawer-body, .drawer-foot { padding-left: 18px; padding-right: 18px; }
  #toasts { bottom: 84px; }
}
@media print {
  #header, #bottomNav, .actions, .tabs { display: none !important; }
  body { background: #fff; }
  .card { border: 0; padding: 0; }
}
.only-mobile { display: none !important; }
@media (max-width: 760px) { .only-mobile { display: flex !important; } }
.search-btn { display: none; }
@media (max-width: 1280px) { .search { display: none; } .search-btn { display: inline-flex; } .header-in { gap: 18px; } }
@media (max-width: 760px) { .search-btn { display: none; } }
