:root {
  --bg: #f7f6f2; --surface: #ffffff; --text: #1f2328; --muted: #646b75; --border: #dedad0;
  --primary: #1d2b3a; --gold: #b8912a; --gold-soft: #f3ead2;
  --p1: #b42318; --p2: #c4610b; --p3: #a8841c; --p4: #6b7a8c; --ok: #2e7d4f; --bad: #b42318;
  --radius: 8px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text); background: var(--bg); font-size: 15px; line-height: 1.5;
}
* { box-sizing: border-box; }
body { margin: 0; }
a { color: var(--primary); }
code, .mono { font-family: ui-monospace, "SFMono-Regular", Menlo, monospace; font-size: 0.86em; }
code { background: var(--gold-soft); padding: 0.05em 0.35em; border-radius: 4px; }
.muted { color: var(--muted); } .small { font-size: 0.85em; }

header.top { display: flex; align-items: center; gap: 2rem; padding: 0.8rem 1.5rem;
             background: var(--primary); color: #fff; }
.brand { color: #fff; font-weight: 700; text-decoration: none; letter-spacing: 0.02em;
         display: flex; align-items: center; gap: 0.6rem; font-size: 1.1rem; }
.seam { width: 22px; height: 22px; border-radius: 50%; background:
        linear-gradient(135deg, transparent 45%, var(--gold) 45% 55%, transparent 55%), #34465a; }
nav { display: flex; gap: 0.3rem; }
nav a { color: #d6dde6; text-decoration: none; padding: 0.35rem 0.8rem; border-radius: 6px; }
nav a:hover { background: rgba(255,255,255,0.08); color: #fff; }
nav a[aria-current="page"] { background: rgba(255,255,255,0.14); color: #fff; }
.who { margin-left: auto; display: flex; align-items: center; gap: 0.8rem; color: #d6dde6;
       font-size: 0.9rem; }
.who .role { color: #aab6c3; }
.who button.link { background: none; border: 1px solid rgba(255,255,255,0.3); color: #fff;
                   border-radius: 6px; padding: 0.25rem 0.7rem; cursor: pointer; }
.login { max-width: 30rem; margin: 3rem auto; }
.login form { display: grid; gap: 0.9rem; }
.login input { width: 100%; }

main { max-width: 1180px; margin: 0 auto; padding: 1.8rem 1.5rem 4rem; }
h1 { font-size: 1.7rem; margin: 0 0 0.4rem; }
h2 { font-size: 1.15rem; margin: 2.2rem 0 0.8rem; padding-bottom: 0.3rem; border-bottom: 2px solid var(--gold-soft); }
.lead { color: var(--muted); margin: 0 0 1.4rem; }
.crumbs { margin: 0 0 0.3rem; font-size: 0.9em; }
.title-row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }

button, .button { font: inherit; border: 1px solid var(--primary); background: var(--primary); color: #fff;
                  padding: 0.42rem 0.95rem; border-radius: 6px; cursor: pointer; text-decoration: none;
                  display: inline-block; }
button:hover, .button:hover { background: #2a3d52; }
button.secondary, .button.secondary { background: var(--surface); color: var(--primary); }
button.secondary:hover, .button.secondary:hover { background: var(--gold-soft); }
button:focus-visible, .button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible,
textarea:focus-visible, summary:focus-visible {
  outline: 2px solid var(--gold); outline-offset: 2px; }
button.compact, .button.compact { padding: 0.22rem 0.65rem; font-size: 0.88em; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
                   clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

table.list { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border);
             border-radius: var(--radius); overflow: hidden; }
table.list th, table.list td { padding: 0.6rem 0.8rem; text-align: left; vertical-align: top;
                               border-bottom: 1px solid var(--border); }
table.list thead th { background: #f0eee7; font-size: 0.82em; text-transform: uppercase; letter-spacing: 0.04em;
                      color: var(--muted); }
table.list tr.job-row td { padding: 0; border-bottom: 0; }
table.list tr.job-row td:not(:empty) { padding: 0 0.8rem 0.8rem; border-bottom: 1px solid var(--border); }
td.actions { text-align: right; white-space: nowrap; }

.prio { display: inline-block; min-width: 2.4em; text-align: center; color: #fff; font-weight: 600; font-size: 0.78em;
        border-radius: 5px; padding: 0.1em 0.45em; margin-right: 0.2em; }
.prio.P1 { background: var(--p1); } .prio.P2 { background: var(--p2); }
.prio.P3 { background: var(--p3); } .prio.P4 { background: var(--p4); }
.prio.zero { background: #e6e3da; color: #8a8f96; }
.tag { display: inline-block; font-size: 0.75em; background: var(--gold-soft); color: #6b5310;
       border-radius: 4px; padding: 0.05em 0.45em; margin-top: 0.2rem; }

.empty, .error { background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius);
                 padding: 1.2rem; color: var(--muted); }
.error { border: 1px solid var(--bad); color: var(--bad); margin-bottom: 1rem; }

.job { background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--gold);
       border-radius: var(--radius); padding: 0.8rem 1rem; margin: 0.6rem 0; }
.job-head { font-weight: 500; }
.events { margin: 0.4rem 0 0; padding-left: 1.1rem; font-size: 0.9em; }
.events .ok { color: var(--ok); } .events .bad { color: var(--bad); }
.spinner { display: inline-block; width: 0.9em; height: 0.9em; border: 2px solid var(--gold-soft);
           border-top-color: var(--gold); border-radius: 50%; animation: spin 0.8s linear infinite;
           vertical-align: -0.1em; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }

details { margin-top: 1rem; } summary { cursor: pointer; color: var(--muted); }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
         padding: 1.1rem; display: flex; flex-direction: column; gap: 0.85rem; }
.panel.narrow { max-width: 560px; }
label { display: flex; flex-direction: column; gap: 0.25rem; font-weight: 500; font-size: 0.93em; }
label.inline { flex-direction: row; align-items: center; gap: 0.45rem; font-weight: 400; }
fieldset { border: 0; padding: 0; margin: 0; display: flex; gap: 1rem; flex-wrap: wrap; }
legend { font-weight: 500; font-size: 0.93em; margin-bottom: 0.25rem; }
input, select, textarea { font: inherit; padding: 0.4rem 0.55rem; border: 1px solid var(--border); border-radius: 6px;
                background: #fff; }
.hint { font-weight: 400; color: var(--muted); font-size: 0.85em; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; }

.report-layout { display: grid; grid-template-columns: 340px 1fr; gap: 1.2rem; align-items: start; }
.preview { width: 100%; height: 78vh; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; }
@media (max-width: 900px) { .report-layout { grid-template-columns: 1fr; } .preview { height: 70vh; } }
.files { padding-left: 1.1rem; } .files li { margin: 0.2rem 0; }

.themes { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 1rem; }
.theme { margin: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
         overflow: hidden; }
.theme img { width: 100%; height: auto; display: block; border-bottom: 1px solid var(--border); background: #fff;
             aspect-ratio: 210 / 297; object-fit: cover; }
.theme figcaption { padding: 0.65rem 0.8rem; display: flex; flex-direction: column; gap: 0.15rem; }

ul.checks { list-style: none; padding: 0; margin: 0; background: var(--surface); border: 1px solid var(--border);
            border-radius: var(--radius); }
ul.checks li { display: flex; gap: 0.8rem; padding: 0.7rem 0.9rem; border-bottom: 1px solid var(--border); }
ul.checks li:last-child { border-bottom: 0; }
.check .dot { flex: none; width: 1.5rem; height: 1.5rem; border-radius: 50%; color: #fff; font-weight: 700;
              display: inline-flex; align-items: center; justify-content: center; font-size: 0.85rem; }
.check.ok .dot { background: var(--ok); } .check.warn .dot { background: var(--p2); }
.check.bad .dot { background: var(--bad); } .check.none .dot { background: #9aa3ad; }

.settings { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
            padding: 0.6rem 0.9rem; margin: 0.6rem 0; }

/* ---------------------------------------------------------------- operazioni */
.toolbar { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; margin: 0.9rem 0 0.2rem; }
.toolbar-label { font-size: 0.82em; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted);
                 margin-right: 0.3rem; }
.toolbar form, .actions form, td.actions form { margin: 0; }
.toolbar-notes { margin: 0.3rem 0 0.4rem; padding-left: 1.1rem; }
.toolbar-notes li { margin: 0.1rem 0; }
.jobs:empty { display: none; }
.job.done { border-left-color: var(--ok); }
.job.failed { border-left-color: var(--bad); }
.mark { display: inline-flex; width: 1.25rem; height: 1.25rem; border-radius: 50%; align-items: center;
        justify-content: center; color: #fff; font-size: 0.78rem; font-weight: 700; vertical-align: -0.15em; }
.mark.ok { background: var(--ok); } .mark.bad { background: var(--bad); }
.events .log { color: var(--text); white-space: pre-wrap; overflow-wrap: anywhere; list-style: none;
               margin-left: -1.1rem; }
.notice { background: #eaf4ee; border: 1px solid #b9dcc6; border-left: 3px solid var(--ok); color: #1d4d31;
          border-radius: var(--radius); padding: 0.55rem 0.9rem; margin: 0.6rem 0; }

/* ---------------------------------------------------------------- triage */
details.triage, details.history { margin-top: 0.45rem; }
details.triage > summary, details.history > summary { font-size: 0.86em; display: inline-block;
  padding: 0.1rem 0.5rem; border: 1px solid var(--border); border-radius: 5px; background: #fbfaf7; }
details.triage > summary:hover, details.history > summary:hover { background: var(--gold-soft); color: var(--text); }
details.triage[open] > summary, details.history[open] > summary { background: var(--gold-soft); color: var(--text); }
.triage-form { display: flex; flex-direction: column; gap: 0.7rem; margin-top: 0.55rem; padding: 0.85rem;
               background: #fbfaf7; border: 1px solid var(--border); border-radius: var(--radius); max-width: 640px; }
.triage-form .decision { flex-direction: column; gap: 0.35rem; }
.choice { flex-direction: row; align-items: flex-start; gap: 0.5rem; font-weight: 400; }
.choice input { margin-top: 0.3rem; }
textarea { resize: vertical; min-height: 3.2rem; }
.form-error { margin: 0; padding: 0.45rem 0.7rem; border: 1px solid var(--bad); border-radius: 6px;
              background: #fdf0ef; color: var(--bad); font-weight: 500; font-size: 0.92em;
              overflow-wrap: anywhere; }
/* Larghezza in percentuale: i campi non allargano la colonna della tabella. */
.triage-form select, .triage-form textarea, .triage-form input:not([type="radio"]) {
  width: 100%; min-width: 0; max-width: 100%; }
/* Senza :has() tutti i campi restano visibili, con il loro "solo per…". */
@supports selector(:has(*)) {
  .triage-form .when-vex, .triage-form .when-accepted { display: none; }
  .triage-form:has(input[value="not_affected"]:checked) .when-vex,
  .triage-form:has(input[value="accepted"]:checked) .when-accepted { display: flex; }
}
.decision-note { margin-top: 0.3rem; }
.history-list { margin: 0.4rem 0 0; padding-left: 1.3rem; font-size: 0.86em; }
.history-list li { margin: 0.25rem 0; }
td.actions-cell { text-align: right; white-space: nowrap; }
form.reopen { margin: 0; }

/* ---------------------------------------------------------------- tabelle piccole */
table.list.compact th, table.list.compact td { padding: 0.45rem 0.7rem; }
.plan-mark { display: inline-block; width: 1.1em; text-align: center; }
tr.plan-run .plan-mark, tr.plan-partial .plan-mark { color: var(--gold); }
tr.plan-missing .plan-mark { color: var(--bad); }
tr.plan-skip td, tr.plan-na td { color: var(--muted); }
table.plan td { font-size: 0.9em; }
.yes { color: var(--ok); font-weight: 600; } .no { color: var(--bad); font-weight: 600; }
.path { overflow-wrap: anywhere; }
.tag.warn { background: #fbe7d3; color: #7a3a05; }
.tag.draft { background: #ece9e1; color: #4a4f57; }
.tag.final { background: #e3f1e8; color: #1d4d31; }
.snapshot { margin: 0 0 0.2rem; }

/* ---------------------------------------------------------------- storico dei report */
.filter { display: flex; align-items: flex-end; gap: 0.6rem; flex-wrap: wrap; margin-bottom: 0.8rem; }
.filter label.inline { gap: 0.5rem; font-weight: 500; }
.history-group h3 { font-size: 1rem; margin: 1.2rem 0 0.5rem; }
.job-details { margin-top: 0.3rem; } .job-details > summary { font-size: 0.86em; }
.preferences { margin: 1rem 0; }
.preferences > summary { font-weight: 600; }
.preferences-form { display: flex; flex-direction: column; gap: 1.3rem; margin-top: 1rem; }
.preferences-form fieldset { display: block; min-width: 0; }
.preferences-form fieldset > label { margin-top: 0.6rem; }
.preferences-form legend { font-weight: 600; }
.preferences-choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0.45rem 1rem; align-content: start; margin: 0.6rem 0; }
.preferences-profiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.3rem; }
.preferences-form input:not([type="checkbox"]), .preferences-form select, .preferences-form textarea { min-width: 0; width: 100%; }
.preferences-form > button { align-self: flex-start; }
.owasp-review { border-top: 1px solid var(--border); padding-top: 0.8rem; margin-top: 1rem; }
@media (max-width: 700px) { .preferences-profiles { grid-template-columns: 1fr; } }
@media (max-width: 500px) { header.top { flex-wrap: wrap; gap: 0.5rem; } nav { flex-wrap: wrap; } }

/* ---------------------------------------------------------------- superficie esterna */
.surface-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
                padding: 0.8rem 1rem; margin: 0 0 0.9rem; }
.surface-card h3 { font-size: 1rem; margin: 0 0 0.2rem; }
.surface-card h4 { font-size: 0.92rem; margin: 1rem 0 0.35rem; }
.chips { list-style: none; padding: 0; margin: 0.5rem 0 0; display: flex; flex-wrap: wrap; gap: 0.4rem; }
.chip { font-size: 0.85em; padding: 0.2rem 0.6rem; border-radius: 999px; border: 1px solid var(--border);
        background: #f6f7f9; }
.chip.good { background: #e3f1e8; border-color: #b9dcc6; }
.chip.warn { background: #fbe7d3; border-color: #f0c9a0; }
.chip.bad { background: #f9dcd9; border-color: #eba9a2; }
.surface-items th { width: 11rem; white-space: nowrap; }
.verdict { display: inline-block; width: 0.65rem; height: 0.65rem; border-radius: 50%; margin-right: 0.45rem;
           background: #9aa3ad; }
.verdict.good { background: var(--ok); } .verdict.warn { background: var(--p2); } .verdict.bad { background: var(--bad); }
.surface-names { columns: 2; column-gap: 2rem; padding-left: 1.2rem; margin: 0.3rem 0; font-size: 0.9em; }
.surface-names li { break-inside: avoid; overflow-wrap: anywhere; }
@media (max-width: 700px) { .surface-names { columns: 1; } }
/* Percorso di rete: riquadri collegati da frecce, come nel report. */
.route-flow { list-style: none; display: flex; flex-wrap: wrap; gap: 0.5rem 1.6rem; padding: 0; margin: 0.4rem 0; }
.route-flow li { position: relative; display: flex; flex-direction: column; align-items: center; min-width: 8.5rem; padding: 0.25rem 0.6rem; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); }
.route-flow li:not(:last-child)::after { content: "→"; position: absolute; right: -1.25rem; top: 50%; transform: translateY(-50%); color: var(--muted); }
.route-flow .start { background: var(--primary); border-color: var(--primary); color: #fff; }
.route-flow .site { border-color: var(--ok); border-width: 2px; }
.route-flow .site.unreached { border-color: var(--muted); border-style: dashed; }
