:root {
  --ink: #16181d;
  --ink-2: #4a505c;
  --ink-3: #7b8190;
  --line: #e2e4e9;
  --line-2: #cfd3da;
  --bg: #f5f6f8;
  --panel: #ffffff;
  --accent: #1d4ed8;
  --accent-soft: #e8eefc;
  --a: #9aa1ad;
  --b: #5b6475;
  --c: #1d4ed8;
  --warn: #9a3412;
  --warn-soft: #fff4ec;
  --ok: #166534;
  --radius: 10px;
  --font: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); color: var(--ink); background: var(--bg);
  font-size: 14px; line-height: 1.45;
}
h1, h2, h3 { margin: 0 0 .5rem; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; }
h3 { font-size: .95rem; }
.muted { color: var(--ink-3); }
.small { font-size: .8rem; font-weight: 400; }
.hidden { display: none !important; }
small { color: var(--ink-3); font-weight: 400; }

/* ── header ─────────────────────────── */
.top {
  position: sticky; top: 0; z-index: 10; background: var(--ink); color: #fff;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .6rem 1.25rem; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: .7rem; }
.brand small { display: block; color: #aab0bc; font-size: .72rem; }
.mark {
  width: 32px; height: 32px; border-radius: 7px; background: #fff; color: var(--ink);
  display: grid; place-items: center; font-weight: 800;
}
.tabs { display: flex; gap: .25rem; flex-wrap: wrap; }
.tabs button {
  background: transparent; color: #c9ced8; border: 0; padding: .45rem .8rem;
  border-radius: 6px; font: inherit; cursor: pointer;
}
.tabs button:hover { color: #fff; background: #ffffff14; }
.tabs button.active { color: var(--ink); background: #fff; font-weight: 600; }

main { max-width: 1440px; margin: 0 auto; padding: 1.25rem; }
.tab { display: none; }
.tab.active { display: block; }

.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem 1.15rem; margin-bottom: 1rem;
}
.panel.two { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }

/* ── layout stima ───────────────────── */
.stima-grid { display: grid; grid-template-columns: minmax(360px, 520px) 1fr; gap: 1.25rem; align-items: start; }
.results { position: sticky; top: 72px; max-height: calc(100vh - 88px); overflow: auto; padding-right: 2px; }

.form-head { display: flex; flex-direction: column; gap: .5rem; margin-bottom: .5rem; }
.examples { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; font-size: .85rem; }

fieldset {
  border: 0; border-top: 1px solid var(--line); margin: 0; padding: .9rem 0 .4rem;
  display: grid; grid-template-columns: 1fr 1fr; gap: .65rem .9rem;
}
legend { font-weight: 650; padding: 0 0 .4rem; font-size: .9rem; }
.tag {
  display: inline-block; font-size: .7rem; font-weight: 700; letter-spacing: .03em;
  background: var(--ink); color: #fff; border-radius: 4px; padding: 1px 6px; margin-right: .35rem;
  vertical-align: 1px;
}
label { display: flex; flex-direction: column; gap: .25rem; font-size: .82rem; color: var(--ink-2); }
label.full, .full { grid-column: 1 / -1; }
input, select, textarea {
  font: inherit; color: var(--ink); background: #fff; border: 1px solid var(--line-2);
  border-radius: 7px; padding: .45rem .55rem; width: 100%; min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
input[type=range] { padding: 0; border: 0; accent-color: var(--ink); }
input[type=checkbox] { width: auto; accent-color: var(--ink); }
.inline { display: flex; gap: .4rem; }
.inline .unit { max-width: 70px; }
output { font-weight: 700; color: var(--ink); }

.dist-head { display: flex; justify-content: space-between; font-size: .82rem; color: var(--ink-2); margin-bottom: .35rem; }
.dist-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .45rem .7rem; }
.dist-grid label { font-size: .76rem; }
.sum { font-weight: 700; color: var(--ok); }
.sum.bad { color: var(--warn); }

.checks { display: flex; flex-direction: column; gap: .35rem; }
.checks label { flex-direction: row; align-items: flex-start; gap: .5rem; font-size: .83rem; color: var(--ink); }

.actions { display: flex; gap: .5rem; flex-wrap: wrap; padding-top: 1rem; border-top: 1px solid var(--line); margin-top: .5rem; }
.actions.inline { border: 0; padding: 0; margin: 0; align-items: center; }
.actions.inline input { width: 220px; }
button, .button {
  font: inherit; font-weight: 550; padding: .5rem .9rem; border-radius: 7px; cursor: pointer;
  border: 1px solid var(--line-2); background: #fff; color: var(--ink); text-decoration: none;
  display: inline-flex; align-items: center; gap: .35rem; white-space: nowrap;
}
button:hover, .button:hover { border-color: var(--ink-3); }
button.primary { background: var(--ink); color: #fff; border-color: var(--ink); }
button.primary:hover { background: #000; }
button.link { border: 0; background: none; padding: 0; color: var(--accent); font-weight: 550; }
button.link:hover { text-decoration: underline; }
button.danger { color: var(--warn); }
button.sm, .button.sm { padding: .25rem .55rem; font-size: .8rem; }

/* ── risultati ──────────────────────── */
.empty { color: var(--ink-3); text-align: center; padding: 3rem 1rem; }
.error { background: var(--warn-soft); color: var(--warn); border: 1px solid #f3c7a8; border-radius: var(--radius); padding: .7rem 1rem; margin-bottom: 1rem; }

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: .75rem; margin-bottom: 1rem; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem .9rem; }
.kpi .lbl { font-size: .74rem; color: var(--ink-3); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.kpi .val { font-size: 1.35rem; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: .2rem; letter-spacing: -.01em; }
.kpi .sub { font-size: .78rem; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.kpi.main { background: var(--ink); color: #fff; border-color: var(--ink); }
.kpi.main .lbl, .kpi.main .sub { color: #c4c9d3; }
.delta-up { color: var(--warn); }
.delta-down { color: var(--ok); }
.kpi.main .delta-up { color: #fdba74; }
.kpi.main .delta-down { color: #86efac; }

table { border-collapse: collapse; width: 100%; font-size: .84rem; }
th, td { padding: .42rem .5rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-size: .74rem; color: var(--ink-3); font-weight: 650; text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; }
table.num td, table.num th { font-variant-numeric: tabular-nums; }
table.num td.r, table.num th.r { text-align: right; }
tr.total td { font-weight: 700; border-top: 2px solid var(--ink); border-bottom: 0; }
.table-wrap { overflow-x: auto; }
td .bar-in { display: inline-block; height: 6px; background: var(--c); border-radius: 3px; vertical-align: middle; }

.bars { display: grid; grid-template-columns: 150px 1fr 110px; gap: .45rem .75rem; align-items: center; font-size: .84rem; }
.bars .track { background: #f0f1f4; height: 18px; border-radius: 4px; position: relative; overflow: hidden; }
.bars .fill { height: 100%; border-radius: 4px; }
.bars .v { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.bars .range { position: absolute; top: 0; height: 100%; border-left: 2px solid var(--ink); border-right: 2px solid var(--ink); background: repeating-linear-gradient(45deg, #16181d22 0 4px, transparent 4px 8px); }

.risk-score { display: flex; align-items: baseline; gap: .6rem; }
.risk-score .n { font-size: 2rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.risk-level { font-weight: 700; padding: 2px 8px; border-radius: 5px; font-size: .8rem; }
.lvl-low, .lvl-Basso { background: #dcfce7; color: #166534; }
.lvl-moderate, .lvl-Moderato { background: #fef9c3; color: #854d0e; }
.lvl-high, .lvl-Alto { background: #ffedd5; color: #9a3412; }
.lvl-critical, .lvl-Critico { background: #fee2e2; color: #991b1b; }
.scale { position: relative; height: 8px; border-radius: 4px; margin: .6rem 0 .3rem;
  background: linear-gradient(90deg, #bbf7d0 0 25%, #fef08a 25% 50%, #fed7aa 50% 75%, #fecaca 75% 100%); }
.scale .pin { position: absolute; top: -4px; width: 3px; height: 16px; background: var(--ink); border-radius: 2px; }
.scale-lbl { display: flex; justify-content: space-between; font-size: .7rem; color: var(--ink-3); }
.risk-parts { font-size: .8rem; color: var(--ink-2); margin-top: .5rem; font-variant-numeric: tabular-nums; }

dl { display: grid; grid-template-columns: auto 1fr; gap: .3rem .9rem; margin: 0; font-size: .84rem; }
dt { color: var(--ink-3); }
dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }

.mc-stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: .5rem; margin-top: .6rem; }
.mc-stats div { border: 1px solid var(--line); border-radius: 7px; padding: .4rem .55rem; }
.mc-stats b { display: block; font-variant-numeric: tabular-nums; }
.mc-stats span { font-size: .72rem; color: var(--ink-3); }
svg text { font-family: var(--font); }

.warnings { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: .45rem; }
.warnings li { background: var(--warn-soft); border-left: 3px solid var(--warn); padding: .45rem .7rem; border-radius: 0 6px 6px 0; font-size: .84rem; }
.warnings li.ok { background: #f0fdf4; border-color: var(--ok); }
.disclaimer { margin-top: .5rem; }

/* ── archivio / calibrazione / coefficienti ── */
.status { font-size: .74rem; font-weight: 700; padding: 2px 7px; border-radius: 5px; background: #eef0f3; color: var(--ink-2); }
.status.chiuso { background: var(--ink); color: #fff; }
.row-actions { display: flex; gap: .35rem; flex-wrap: wrap; }
.actuals-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem .9rem; }
.metric-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .75rem; margin: .75rem 0 1rem; }
.better { color: var(--ok); font-weight: 700; }
.worse { color: var(--warn); font-weight: 700; }
.notes { font-size: .82rem; color: var(--ink-2); padding-left: 1.1rem; }

.coef-table input { width: 64px; padding: .3rem .35rem; text-align: right; font-variant-numeric: tabular-nums; font-size: .8rem; }
.coef-table td { white-space: nowrap; }
.coef-table .trip { display: inline-flex; gap: 3px; }
.coef-block { margin-bottom: 1.5rem; }
.history { font-size: .82rem; color: var(--ink-2); padding-left: 1.1rem; }
.prose { max-width: 820px; }
.prose li { margin-bottom: .3rem; }

.toast { position: fixed; bottom: 1.25rem; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff;
  padding: .6rem 1rem; border-radius: 8px; font-size: .88rem; box-shadow: 0 8px 24px #0003; z-index: 50; }
.print-only { display: none; }

@media (max-width: 1100px) {
  .stima-grid { grid-template-columns: 1fr; }
  .results { position: static; max-height: none; }
}
@media (max-width: 640px) {
  main { padding: .75rem; }
  fieldset, .panel.two, .actuals-grid, .metric-grid { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .dist-grid { grid-template-columns: 1fr 1fr; }
  .bars { grid-template-columns: 90px 1fr 80px; }
  .mc-stats { grid-template-columns: repeat(3, 1fr); }
}

@media print {
  body { background: #fff; font-size: 11px; }
  .top, .form, .tab:not(#tab-stima), .actions, #toast { display: none !important; }
  main { padding: 0; max-width: none; }
  .stima-grid { display: block; }
  .results { position: static; max-height: none; overflow: visible; }
  .panel, .kpi { break-inside: avoid; border-color: #bbb; }
  .print-only { display: block; }
  .print-head { border-bottom: 2px solid #000; margin-bottom: 1rem; padding-bottom: .5rem; }
  .kpi.main { background: #fff; color: #000; border: 2px solid #000; }
  .kpi.main .lbl, .kpi.main .sub { color: #333; }
}

/* ── metodi di stima ───────────────── */
.method-switch { display: flex; flex-wrap: wrap; gap: 4px; background: #eef0f3; padding: 4px; border-radius: 9px; }
.method-switch button { flex: 1 1 auto; border: 0; background: transparent; padding: .42rem .6rem; font-size: .82rem; font-weight: 600; color: var(--ink-2); border-radius: 6px; }
.method-switch button.active { background: #fff; color: var(--ink); box-shadow: 0 1px 2px #0002; }
.method-hint { margin: -.2rem 0 0; }
.form .sub { border: 1px solid var(--line); border-radius: 8px; padding: .65rem .75rem; background: #fafbfc; }
.sub-head { font-size: .82rem; margin: .2rem 0 .45rem; }
.sub-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .55rem .8rem; margin-bottom: .5rem; }
.sub-grid.four { grid-template-columns: repeat(4, 1fr); }
.check-inline { flex-direction: row; align-items: center; gap: .45rem; align-self: end; padding-bottom: .5rem; }
.fn-table, .pert-table { font-size: .78rem; }
.fn-table th, .fn-table td, .pert-table th, .pert-table td { padding: .25rem .25rem; border-bottom: 1px solid var(--line); }
.fn-table input, .fn-table select, .pert-table input { padding: .28rem .3rem; font-size: .78rem; border-radius: 5px; }
.fn-table td.fp { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.fn-table .w-name { min-width: 120px; }
.fn-table .w-num { width: 52px; }
.fn-table .x { border: 0; background: none; color: var(--ink-3); padding: 0 .2rem; font-size: 1rem; }
.fn-table .x:hover { color: var(--warn); }
.gsc-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .3rem .8rem; }
.gsc-grid label { flex-direction: row; align-items: center; justify-content: space-between; gap: .5rem; font-size: .76rem; }
.gsc-grid select { width: 58px; padding: .2rem .25rem; font-size: .78rem; }
.drivers { display: grid; grid-template-columns: repeat(2, 1fr); gap: .3rem .8rem; margin-bottom: .5rem; }
.drivers label { flex-direction: row; align-items: center; justify-content: space-between; gap: .4rem; font-size: .76rem; }
.drivers label b { font-weight: 700; color: var(--ink); min-width: 38px; display: inline-block; }
.drivers select { width: 128px; padding: .22rem .3rem; font-size: .76rem; }
.drivers select.changed { border-color: var(--ink); font-weight: 600; }
.drivers .grp { grid-column: 1 / -1; font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); margin-top: .3rem; font-weight: 650; }
.size-box { display: grid; grid-template-columns: 1fr 1fr; gap: .55rem .8rem; margin-bottom: .55rem; }
.adv summary { cursor: pointer; font-size: .8rem; color: var(--ink-2); margin: .2rem 0 .4rem; }
.base-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: .6rem; margin-bottom: .7rem; }
.base-grid div { border: 1px solid var(--line); border-radius: 7px; padding: .45rem .6rem; }
.base-grid span { display: block; font-size: .72rem; color: var(--ink-3); }
.base-grid b { font-variant-numeric: tabular-nums; font-size: 1.02rem; }
.formula { font-family: var(--mono); font-size: .75rem; color: var(--ink-2); background: #f5f6f8; padding: .4rem .55rem; border-radius: 6px; margin: .4rem 0 0; overflow-x: auto; white-space: nowrap; }
.cx { font-size: .72rem; font-weight: 700; padding: 1px 6px; border-radius: 4px; background: #eef0f3; }
@media (max-width: 640px) {
  .sub-grid, .drivers, .gsc-grid, .size-box { grid-template-columns: 1fr; }
  .base-grid { grid-template-columns: 1fr 1fr; }
}

.fn-table { display: flex; flex-direction: column; gap: .35rem; }
.fn-head, .fn-row { display: grid; grid-template-columns: 62px 46px 50px 58px 1fr 52px; gap: .3rem; align-items: center; }
.fn-head.evol, .fn-row.evol { grid-template-columns: 58px 42px 46px 52px 1fr 92px 46px; }
.fn-head { font-size: .68rem; text-transform: uppercase; letter-spacing: .03em; color: var(--ink-3); font-weight: 650; }
.fn-head .r { text-align: right; }
.fn-row { padding: .35rem 0; border-top: 1px solid var(--line); }
.fn-row .fn-name { grid-column: 1 / -1; display: flex; gap: .3rem; }
.fn-row input, .fn-row select { padding: .28rem .3rem; font-size: .78rem; border-radius: 5px; }
.fn-row .fp { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; font-size: .8rem; }
.fn-row .x { border: 0; background: none; color: var(--ink-3); padding: 0 .3rem; font-size: 1.1rem; }
.fn-row .x:hover { color: var(--warn); }
.drivers label > span { display: flex; flex-direction: column; line-height: 1.15; }
.drivers label > span small { font-size: .7rem; }
.drivers select { width: 96px; }
.drivers .legend { text-transform: none; letter-spacing: 0; font-weight: 400; margin-top: 0; }

/* ── lingua, informazioni, piè di pagina ── */
.top-right { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.lang select {
  background: #ffffff14; color: #fff; border: 1px solid #ffffff33; border-radius: 6px;
  padding: .35rem .5rem; font: inherit; font-size: .84rem; cursor: pointer; width: auto;
}
.lang select option { color: var(--ink); background: #fff; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.foot {
  max-width: 1440px; margin: 0 auto; padding: 1rem 1.25rem 2rem; display: flex; flex-wrap: wrap; gap: .4rem 1.2rem;
  font-size: .76rem; color: var(--ink-3); border-top: 1px solid var(--line);
}
dl.about { grid-template-columns: max-content 1fr; max-width: 640px; margin: .5rem 0 1.2rem; font-size: .9rem; }
dl.about dd { text-align: left; font-weight: 600; }
.coef-table th { text-align: left; font-size: .78rem; color: var(--ink-3); padding-right: .6rem; }
.print-foot { margin-top: 1rem; border-top: 1px solid #bbb; padding-top: .4rem; color: #444; }
@media print { .foot { display: none; } }

/* ── help in linea ── */
.help-btn {
  display: inline-grid; place-items: center; width: 18px; height: 18px; padding: 0; margin-left: .4rem;
  border-radius: 50%; border: 1px solid var(--line); background: #fff; color: var(--ink-2);
  font: 700 11px/1 var(--font); cursor: pointer; vertical-align: middle;
}
.help-btn:hover, .help-btn:focus-visible { background: var(--ink); color: #fff; border-color: var(--ink); }
dialog#help-dlg {
  max-width: 620px; width: calc(100% - 2rem); border: 1px solid var(--line); border-radius: 12px;
  padding: 1.2rem 1.4rem; box-shadow: 0 20px 60px #0004; color: var(--ink);
}
dialog#help-dlg::backdrop { background: #16181d66; }
dialog#help-dlg h2 { margin: 0 0 .6rem; font-size: 1.15rem; }
#help-dlg-body { font-size: .9rem; line-height: 1.5; max-height: 60vh; overflow: auto; }
#help-dlg-body code, #help-all code { font-family: var(--mono); font-size: .8rem; background: #f5f6f8; padding: 2px 5px; border-radius: 4px; }
.dlg-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1rem; }
.guide-head { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; }
.guide-head h2 { margin: 0; flex: 1 1 auto; }
.guide-head input { max-width: 260px; }
.guide-cols { display: grid; grid-template-columns: 230px 1fr; gap: 1.5rem; margin-top: 1rem; }
.guide-toc { position: sticky; top: 72px; align-self: start; display: flex; flex-direction: column; gap: .2rem; font-size: .85rem; }
.guide-toc a { color: var(--ink-2); text-decoration: none; padding: .25rem .5rem; border-radius: 6px; }
.guide-toc a:hover { background: #eef0f3; color: var(--ink); }
#help-all { max-width: 820px; }
.help-sec { padding-bottom: .8rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; scroll-margin-top: 80px; }
.help-sec h3 { margin: .2rem 0 .5rem; }
@media (max-width: 760px) { .guide-cols { grid-template-columns: 1fr; } .guide-toc { position: static; } }
@media print { .help-btn, #btn-pdf-summary, #btn-pdf-detail { display: none !important; } }

/* ── moduli AESTIMETRUM: componenti AI, ciclo di vita, scenari ── */
.form .sub-always { border: 1px solid var(--line); border-radius: 8px; padding: .65rem .75rem; background: #fafbfc; }
.legend { display: flex; flex-wrap: wrap; gap: .4rem 1rem; font-size: .78rem; color: var(--ink-2); margin: .2rem 0 .6rem; }
.legend i { display: inline-block; width: .7rem; height: .7rem; border-radius: 2px; margin-right: .3rem; vertical-align: -1px; }
.tco-kpis { grid-template-columns: repeat(4, 1fr); margin-bottom: .6rem; }
.tco-table td, .tco-table th { white-space: nowrap; font-size: .8rem; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; margin-bottom: .5rem; }
.seg button { border: 0; border-radius: 0; padding: .3rem .7rem; background: #fff; font-size: .8rem; }
.seg button.active { background: var(--ink); color: #fff; }
.readings { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin-bottom: .6rem; }
.readings div { border: 1px solid var(--line); border-radius: 8px; padding: .4rem .6rem; }
.readings span { display: block; font-size: .72rem; color: var(--ink-2); }
.readings b { font-variant-numeric: tabular-nums; }
.scen-table tr.base-row td { background: #f4f6fa; }
@media (max-width: 760px) { .tco-kpis { grid-template-columns: 1fr 1fr; } }
.scen-table td.r { white-space: nowrap; }

/* ── accesso e registrazione ────────── */
.auth-body { min-height: 100vh; display: flex; flex-direction: column; }
.auth-main { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; padding: 3rem 16px 2rem; width: 100%; }
.auth-card { width: 100%; max-width: 420px; padding: 1.6rem 1.6rem 1.3rem; box-shadow: 0 10px 30px #0000000d; }
.auth-form { display: flex; flex-direction: column; gap: .8rem; }
.auth-form h1 { font-size: 1.35rem; margin: 0; }
.auth-form > p { margin: 0; }
.auth-form label { font-size: .84rem; }
.auth-form .check-inline { flex-direction: row; align-items: center; gap: .45rem; align-self: flex-start; padding-bottom: 0; }
button.wide { width: 100%; justify-content: center; padding: .65rem; margin-top: .2rem; }
button:disabled { opacity: .55; cursor: progress; }
.auth-links { display: flex; justify-content: space-between; gap: .75rem; flex-wrap: wrap; font-size: .86rem; }
.auth-links a, .auth-form a { color: var(--accent); text-decoration: none; font-weight: 550; }
.auth-links a:hover { text-decoration: underline; }
.auth-msg { background: var(--warn-soft); color: var(--warn); border: 1px solid #f3c7a8; border-radius: 8px; padding: .55rem .75rem; font-size: .85rem; }
.auth-msg.ok { background: #ecfdf3; color: var(--ok); border-color: #b7e4c7; }
.auth-foot { margin-top: 1.2rem; text-align: center; }
.pw-wrap { position: relative; display: block; }
.pw-wrap input { padding-right: 2.4rem; }
.pw-eye { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); border: 0; background: none; padding: .2rem .4rem; font-size: .9rem; opacity: .6; }
.pw-eye:hover { opacity: 1; }
.pw-meter { height: 5px; border-radius: 3px; background: #eceef2; overflow: hidden; margin-top: -.4rem; }
.pw-meter i { display: block; height: 100%; width: 0; background: var(--warn); transition: width .2s, background .2s; }
.pw-meter[data-s="1"] i { width: 25%; }
.pw-meter[data-s="2"] i { width: 50%; background: #b45309; }
.pw-meter[data-s="3"] i { width: 75%; background: #4d7c0f; }
.pw-meter[data-s="4"] i { width: 100%; background: var(--ok); }
.pw-rules { margin: -.3rem 0 0; }

/* ── menu utente ────────────────────── */
.user-menu { position: relative; }
#user-btn { background: #ffffff14; color: #fff; border: 1px solid #ffffff33; padding: .25rem .6rem .25rem .3rem; font-size: .84rem; max-width: 240px; }
#user-btn:hover { background: #ffffff22; }
#user-label { overflow: hidden; text-overflow: ellipsis; }
.avatar { width: 24px; height: 24px; border-radius: 50%; background: #fff; color: var(--ink); display: inline-grid; place-items: center; font-size: .7rem; font-weight: 800; flex: none; }
.user-pop { position: absolute; right: 0; top: calc(100% + 6px); background: #fff; color: var(--ink); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 32px #0002; min-width: 240px; padding: .4rem; z-index: 30; display: flex; flex-direction: column; }
.user-pop-head { display: flex; flex-direction: column; gap: .15rem; padding: .5rem .6rem .6rem; border-bottom: 1px solid var(--line); margin-bottom: .3rem; }
.user-pop-head .status { align-self: flex-start; margin-top: .2rem; }
.user-pop button { border: 0; background: none; justify-content: flex-start; padding: .5rem .6rem; border-radius: 6px; font-weight: 500; }
.user-pop button:hover { background: var(--bg); }
dialog#account-dlg { border: 1px solid var(--line); border-radius: 12px; padding: 1.3rem 1.4rem; width: min(440px, calc(100vw - 32px)); box-shadow: 0 20px 50px #0003; }
dialog#account-dlg::backdrop { background: #0006; }
#account-form { display: flex; flex-direction: column; gap: .65rem; }
#account-form h3 { margin-bottom: 0; }
#account-form p { margin: 0; }
.note-box { background: var(--accent-soft); color: #1e3a8a; border-radius: 8px; padding: .55rem .8rem; font-size: .85rem; margin: .2rem 0 .6rem; }

/* ── amministrazione ────────────────── */
.ad-kpis { margin-top: .8rem; }
.ad-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; margin-bottom: 1.1rem; }
.ad-grid > div { min-width: 0; }
.ad-chart svg { width: 100%; height: 200px; display: block; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.status.st-active { background: #e7f6ec; color: var(--ok); }
.status.st-pending { background: #fff7e0; color: #8a5a00; }
.status.st-disabled, .status.st-locked { background: var(--warn-soft); color: var(--warn); }
tr.log-fail td { background: #fffaf6; }
.ok-t { color: var(--ok); font-weight: 600; }
.mono { font-family: var(--mono); }
#ad-invite input[type=email] { width: 220px; }
#ad-log-filter input[name=pseudo] { width: 170px; }
#ad-log-filter .check-inline, #ad-invite .check-inline { flex-direction: row; align-items: center; gap: .35rem; white-space: nowrap; align-self: center; padding-bottom: 0; }
@media (max-width: 900px) {
  .ad-grid { grid-template-columns: 1fr; }
  #ad-invite, #ad-log-filter { flex-wrap: wrap; }
  #ad-invite input, #ad-log-filter input[name=pseudo] { width: 100% !important; }
}
@media (max-width: 640px) {
  .auth-main { padding-top: 1.5rem; }
  #user-label { display: none; }
}
.actions.inline input[type=checkbox] { width: auto; }

/* avviso: uso esclusivamente didattico */
.edu-bar { margin: 0; padding: .35rem 1rem; text-align: center; font-size: .85rem;
  background: var(--note-bg, #fff6e0); color: var(--note-fg, #5c4300); border-bottom: 1px solid rgba(0,0,0,.12); }
.auth-main > .edu-bar { border: 1px solid rgba(0,0,0,.12); border-radius: 6px; margin: 0 auto 1rem; max-width: 34rem; }
@media print { .edu-bar { display: none; } }

/* ── WBS: editor e vista ad albero ── */
.wbs-tree { display: flex; flex-direction: column; gap: .3rem; }
.wbs-row { position: relative; border: 1px solid var(--line); border-radius: 8px; padding: .35rem .5rem .45rem; margin-left: calc(var(--lvl, 0) * 14px); background: var(--panel); overflow: hidden; }
.wbs-row.parent { background: var(--bg); }
.wbs-l1 { display: flex; align-items: center; gap: .3rem; }
.wbs-num { font-size: .68rem; color: var(--ink-3); min-width: 1.6rem; font-variant-numeric: tabular-nums; }
.wbs-tg { width: 1.2rem; min-width: 1.2rem; border: 0; background: none; padding: 0; color: var(--ink-2); font-size: .8rem; cursor: pointer; }
.wbs-nm { flex: 1; min-width: 0; padding: .28rem .4rem; font-size: .82rem; border-radius: 5px; }
.wbs-act { display: flex; gap: .15rem; }
.wbs-act button { border: 1px solid var(--line); background: var(--panel); border-radius: 5px; padding: 0 .35rem; line-height: 1.4rem; font-size: .8rem; color: var(--ink-2); cursor: pointer; }
.wbs-act button:disabled { opacity: .35; cursor: default; }
.wbs-act .x { color: var(--warn); }
.wbs-l2 { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .6rem; margin: .3rem 0 0 1.9rem; }
.wbs-row .wbs-f { display: inline-flex; flex-direction: row; align-items: center; gap: .25rem; font-size: .72rem; color: var(--ink-3); margin: 0; }
.wbs-row .wbs-f input[type=checkbox] { width: auto; margin: 0; }
.wbs-f > span { white-space: nowrap; }
.wbs-f input[type=number] { width: 3.6rem; padding: .2rem .3rem; font-size: .78rem; border-radius: 5px; }
.wbs-secl { cursor: pointer; }
.wbs-live { margin-left: auto; font-size: .74rem; color: var(--ink-2); font-variant-numeric: tabular-nums; display: inline-flex; gap: .5rem; }
.wbs-live small { color: var(--ink-3); }
.wbs-d { color: var(--ink-3); }
.wbs-d.bad { color: var(--warn); font-weight: 650; }
.wbs-bar { position: absolute; left: 0; bottom: 0; height: 3px; width: 0; background: var(--accent); opacity: .55; }
.wbs-empty { margin: .2rem 0; }
.wbs-diagram { overflow: auto; border: 1px solid var(--line); border-radius: 8px; padding: .5rem; background: var(--panel); }
.wbs-diagram svg { display: block; max-width: none; }
.wbs-link { fill: none; stroke: var(--line-2); stroke-width: 1.4; }
.wbs-box rect:first-of-type { fill: var(--panel); stroke: var(--line-2); stroke-width: 1.2; }
.wbs-box.leaf rect:first-of-type { fill: var(--bg); }
.wbs-box.root rect:first-of-type { fill: var(--ink); stroke: var(--ink); }
.wbs-box.sec rect:first-of-type { stroke: var(--accent); stroke-width: 2; }
.wbs-box text { font-family: var(--font); fill: var(--ink); }
.wbs-box .nm { font-size: 11.5px; font-weight: 650; }
.wbs-box .vl { font-size: 10.5px; fill: var(--ink-2); font-variant-numeric: tabular-nums; }
.wbs-box.root text { fill: #fff; }
.wbs-box .bar { fill: var(--accent); }
.wbs-box.root .bar { fill: #fff; opacity: .6; }
.wbs-parent-row td { font-weight: 650; }
@media print { .wbs-diagram { overflow: visible; border: 0; padding: 0; } .wbs-diagram svg { max-width: 100%; height: auto; } }

/* ── COSMIC e Use Case Point ── */
.cs-head, .cs-row { display: grid; grid-template-columns: 1fr 44px 44px 44px 44px 46px; gap: .3rem; align-items: center; }
.cs-head { font-size: .68rem; text-transform: uppercase; letter-spacing: .03em; color: var(--ink-3); font-weight: 650; }
.cs-row { margin-top: .25rem; }
.cs-row input, .ucp-row input, .ucp-row select, .ucp-f select { padding: .28rem .3rem; font-size: .78rem; border-radius: 5px; }
.cs-name { display: flex; gap: .2rem; align-items: center; min-width: 0; }
.cs-name input { flex: 1; min-width: 0; }
.cs-name .x { border: 0; background: none; color: var(--ink-3); padding: 0 .2rem; font-size: 1rem; cursor: pointer; }
.cs-row .fp, .ucp-row .fp { text-align: right; font-variant-numeric: tabular-nums; font-size: .78rem; color: var(--ink-2); }
.cs-nc { color: var(--warn); cursor: help; }
.ucp-row { display: grid; gap: .3rem; align-items: center; margin-top: .25rem; }
.ucp-actor { grid-template-columns: 1fr minmax(120px, 1.1fr) 52px 36px; }
.ucp-uc { grid-template-columns: 1fr 76px 96px; }
.ucp-grid { display: grid; grid-template-columns: 1fr; gap: .2rem; margin-top: .35rem; }
.ucp-f { display: grid; grid-template-columns: 1fr 52px; gap: .4rem; align-items: center; font-size: .78rem; }
.ucp-f small { color: var(--ink-3); }

/* Delphi, analogia */
.dl-row { display: grid; gap: .3rem; align-items: center; margin-top: .25rem; }
.dl-head { font-size: .68rem; text-transform: uppercase; letter-spacing: .03em; color: var(--ink-3); font-weight: 650; margin-top: .4rem; }
.dl-row input { padding: .28rem .3rem; font-size: .78rem; border-radius: 5px; min-width: 0; }
.dl-exp { display: flex; align-items: center; gap: .1rem; min-width: 0; }
.dl-exp input { flex: 1; text-transform: none; font-weight: 400; }
.dl-row .x { border: 0; background: none; color: var(--ink-3); padding: 0 .2rem; font-size: 1rem; cursor: pointer; }
.dl-row .fp { text-align: right; font-variant-numeric: tabular-nums; font-size: .78rem; color: var(--ink-2); }
.dl-rn { font-size: .78rem; color: var(--ink-2); }
.dl-bad { color: var(--warn, #b45309); font-weight: 650; }
.an-card { border: 1px solid var(--line, #ddd); border-radius: 8px; padding: .45rem; margin-top: .4rem; }
.an-top { display: grid; grid-template-columns: 1fr 110px 22px; gap: .3rem; align-items: center; }
.an-f { display: grid; grid-template-columns: 1fr 70px 22px; gap: .3rem; align-items: center; margin-top: .25rem; }
.an-card input { padding: .28rem .3rem; font-size: .78rem; border-radius: 5px; min-width: 0; }
.an-card .x { border: 0; background: none; color: var(--ink-3); padding: 0 .2rem; font-size: 1rem; cursor: pointer; }
.an-foot { display: flex; justify-content: space-between; align-items: center; margin-top: .35rem; }

/* Modelli AI */
.aim-card { border: 1px solid var(--line, #ddd); border-radius: 8px; padding: .5rem; margin-top: .45rem; }
.aim-top { display: grid; grid-template-columns: 1fr 1fr 22px; gap: .3rem; align-items: center; }
.aim-top > input { grid-column: 1 / 3; }
.aim-top > .x { grid-row: 1; grid-column: 3; }
.aim-top input, .aim-top select, .aim-total input, .aim-ext input { padding: .28rem .3rem; font-size: .78rem; border-radius: 5px; min-width: 0; }
.aim-top .x { border: 0; background: none; color: var(--ink-3); padding: 0 .2rem; font-size: 1rem; cursor: pointer; }
.aim-total { display: grid; grid-template-columns: repeat(3, 1fr); gap: .3rem; }
.aim-w { display: flex; flex-wrap: wrap; gap: .25rem .6rem; font-size: .7rem; color: var(--ink-3); margin-top: .25rem; }
.aim-ext { margin-top: .4rem; }
.aim-tbl td input { width: 100%; min-width: 0; padding: .25rem .3rem; font-size: .78rem; }
.aim-h { margin: .8rem 0 .3rem; font-size: .85rem; }
.aim-side { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; align-items: start; }
@media (max-width: 720px) { .aim-side { grid-template-columns: 1fr; } }

/* ── storico ─────────────────────────────────── */
.hist-filters { display: flex; flex-wrap: wrap; gap: .6rem 1rem; align-items: flex-end; margin: .75rem 0 1rem; }
.hist-filters fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: .35rem .7rem; display: flex; flex-wrap: wrap; gap: .3rem .9rem; align-items: center; }
.hist-filters legend { font-size: .74rem; color: var(--ink-3); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; padding: 0 .3rem; }
.hist-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(460px, 1fr)); gap: .5rem 1.4rem; margin-bottom: .75rem; }
.hist-cols > div { min-width: 0; }
#hist-root h3 { margin-top: 1.4rem; }
.hist-cols h4, .hist-form h4 { margin: .8rem 0 .3rem; font-size: .9rem; }
.hist-form { border: 1px solid var(--line); background: var(--bg-soft, #f7f8fa); margin: .75rem 0 1rem; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip { background: #eef0f3; border-radius: 999px; padding: 2px 10px; font-size: .82rem; }
.chips-edit { display: flex; flex-wrap: wrap; gap: .3rem 1rem; margin-bottom: .6rem; }
label.inline { display: inline-flex; align-items: center; gap: .35rem; flex-direction: row; font-weight: 400; }
tr.dim td { opacity: .5; }
td.c, th.c { text-align: center; }
.status.out-completed { background: #e7f6ec; color: var(--ok); }
.status.out-early_closed { background: #fff7e0; color: #8a5a00; }
.status.out-failed { background: #fde8e8; color: #a12020; }
.status.out-cancelled { background: #eef0f3; color: var(--ink-2); }
@media (max-width: 900px) { .hist-cols { grid-template-columns: 1fr; } }
