:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --ink: #16191f;
  --muted: #4a5160;
  --line: #dcd7cc;
  --accent: #1d4ed8;
  --accent-hover: #1a3fae;
  --accent-soft: #e7ecfb;
  --dark: #121826;
  --dark-muted: #c3cad8;
  --good: #116b3a;
  --good-soft: #e3f3e9;
  --warn: #8a5a00;
  --warn-soft: #fbf0d9;
  --bad: #b42318;
  --bad-soft: #fde7e5;
  --critical: #b42318;
  --serious: #b5400b;
  --moderate: #8a5a00;
  --minor: #475467;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(18, 24, 38, .06), 0 8px 24px rgba(18, 24, 38, .07);
  --font: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
}

img { max-width: 100%; height: auto; }

a { color: var(--accent); text-underline-offset: 3px; }
a:hover { color: var(--accent-hover); }

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: -100px;
  background: var(--ink);
  color: #fff;
  padding: .75rem 1rem;
  border-radius: 8px;
  z-index: 100;
  text-decoration: none;
}
.skip-link:focus { top: 1rem; color: #fff; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

.wrap { width: min(1120px, 100% - 2rem); margin-inline: auto; }
.wrap-narrow { width: min(820px, 100% - 2rem); margin-inline: auto; }

/* Header */
.site-header {
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}
.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 68px;
}
.logo {
  display: inline-flex;
  align-items: center;
  gap: .6rem;
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--ink);
  text-decoration: none;
}
.logo-mark {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: conic-gradient(var(--accent) 0 75%, var(--line) 75% 100%);
  display: grid; place-items: center;
}
.logo-mark::after {
  content: "";
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--bg);
}
.header-cta { font-weight: 700; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  min-height: 48px;
  padding: .75rem 1.4rem;
  border: 2px solid var(--accent);
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}
.btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
.btn[disabled] { opacity: .6; cursor: progress; }
.btn-ghost { background: transparent; color: var(--accent); }
.btn-ghost:hover { background: var(--accent-soft); color: var(--accent-hover); }
.btn-light { background: #fff; color: var(--dark); border-color: #fff; }
.btn-light:hover { background: var(--accent-soft); color: var(--dark); border-color: var(--accent-soft); }
.btn-block { width: 100%; }

/* Hero */
.hero { padding: clamp(2.5rem, 6vw, 5rem) 0 3.5rem; }
.hero-grid {
  display: grid;
  grid-template-columns: 1.05fr .95fr;
  gap: clamp(2rem, 5vw, 4rem);
  align-items: start;
}
.eyebrow {
  display: inline-block;
  font-size: .85rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: .75rem;
}
h1, h2, h3 { line-height: 1.15; margin: 0 0 .75rem; }
h1 { font-size: clamp(2.1rem, 4.6vw, 3.3rem); letter-spacing: -.02em; }
h2 { font-size: clamp(1.6rem, 3vw, 2.2rem); letter-spacing: -.01em; }
h3 { font-size: 1.2rem; }
.lead { font-size: 1.2rem; color: var(--muted); max-width: 34ch; margin: 0 0 1.5rem; }
.trust {
  list-style: none;
  padding: 0;
  margin: 1.5rem 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: .5rem 1.5rem;
  color: var(--muted);
  font-weight: 700;
  font-size: .95rem;
}
.trust li::before { content: "✓ "; color: var(--good); }

/* Card / form */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(1.25rem, 3vw, 2rem);
}
.form-title { font-size: 1.35rem; margin-bottom: .25rem; }
.form-sub { color: var(--muted); margin: 0 0 1.25rem; font-size: .98rem; }
.field { margin-bottom: 1rem; }
.field label { display: block; font-weight: 700; margin-bottom: .35rem; }
.field .hint { display: block; color: var(--muted); font-size: .9rem; margin-top: .3rem; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
input[type="text"], input[type="email"], input[type="url"], input[type="password"] {
  width: 100%;
  min-height: 48px;
  padding: .65rem .85rem;
  border: 2px solid #8b8f99;
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}
input:focus-visible { border-color: var(--accent); outline-offset: 1px; }
input[aria-invalid="true"] { border-color: var(--bad); }
.check {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: .6rem;
  align-items: start;
  margin-bottom: .75rem;
  font-size: .95rem;
}
.check input { width: 22px; height: 22px; margin: 2px 0 0; accent-color: var(--accent); }
.optional { font-weight: 400; color: var(--muted); }
.form-error {
  background: var(--bad-soft);
  color: var(--bad);
  border-left: 4px solid var(--bad);
  padding: .75rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-weight: 700;
}
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.small { font-size: .88rem; color: var(--muted); }

/* Progress */
.progress-panel { text-align: center; padding: 1rem 0; }
.spinner {
  width: 64px; height: 64px;
  margin: 0 auto 1.25rem;
  border-radius: 50%;
  border: 6px solid var(--accent-soft);
  border-top-color: var(--accent);
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.progress-steps { list-style: none; padding: 0; margin: 1.25rem 0 0; text-align: left; }
.progress-steps li { padding: .35rem 0 .35rem 1.8rem; position: relative; color: var(--muted); }
.progress-steps li::before {
  content: ""; position: absolute; left: 0; top: .7rem;
  width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line);
}
.progress-steps li.done { color: var(--ink); }
.progress-steps li.done::before { background: var(--good); border-color: var(--good); }
.progress-steps li.active { color: var(--ink); font-weight: 700; }
.progress-steps li.active::before { border-color: var(--accent); background: var(--accent-soft); }

/* Sections */
.section { padding: clamp(3rem, 7vw, 5rem) 0; }
.section-alt { background: var(--surface); border-block: 1px solid var(--line); }
.section-head { max-width: 640px; margin-bottom: 2.25rem; }
.section-head p { color: var(--muted); margin: 0; }

.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.25rem; counter-reset: step; list-style: none; padding: 0; margin: 0; }
.steps li { counter-increment: step; }
.steps li::before {
  content: counter(step);
  display: grid; place-items: center;
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--accent); color: #fff; font-weight: 700; font-size: 1.15rem;
  margin-bottom: 1rem;
}
.steps p { color: var(--muted); margin: 0; }

.checks-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; list-style: none; padding: 0; margin: 0; }
.checks-grid li {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1.1rem 1.2rem;
}
.checks-grid strong { display: block; margin-bottom: .25rem; }
.checks-grid span { color: var(--muted); font-size: .95rem; }

.law-grid { display: grid; grid-template-columns: 1.2fr .8fr; gap: 2rem; align-items: start; }
.facts { list-style: none; padding: 0; margin: 0; display: grid; gap: .75rem; }
.facts li { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 1rem 1.2rem; }
.facts b { display: block; font-size: 1.5rem; color: var(--accent); line-height: 1.2; }
.note {
  border-left: 4px solid var(--warn);
  background: var(--warn-soft);
  padding: .9rem 1.1rem;
  border-radius: 8px;
  color: #4d3400;
  font-size: .95rem;
}

.faq details {
  border-bottom: 1px solid var(--line);
  padding: 1rem 0;
}
.faq summary {
  cursor: pointer;
  font-weight: 700;
  font-size: 1.1rem;
  list-style: none;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; font-size: 1.4rem; line-height: 1; color: var(--accent); }
.faq details[open] summary::after { content: "−"; }
.faq details p { color: var(--muted); margin: .75rem 0 0; }

.cta-band { background: var(--dark); color: #fff; border-radius: 20px; padding: clamp(2rem, 5vw, 3.25rem); display: grid; grid-template-columns: 1fr auto; gap: 2rem; align-items: center; }
.cta-band p { color: var(--dark-muted); margin: 0; max-width: 52ch; }
.cta-band :focus-visible { outline-color: #fff; }

.site-footer { padding: 2.5rem 0; color: var(--muted); font-size: .92rem; }
.site-footer .wrap { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem; }

/* Demo card in hero */
.demo { margin-top: 2rem; }
.demo-row { display: flex; align-items: center; gap: 1rem; }
.demo-bars { flex: 1; display: grid; gap: .5rem; }
.demo-bar { display: grid; grid-template-columns: 90px 1fr 26px; gap: .5rem; align-items: center; font-size: .85rem; color: var(--muted); }
.demo-bar span.track { height: 8px; background: var(--bg); border-radius: 99px; overflow: hidden; }
.demo-bar span.fill { display: block; height: 100%; border-radius: 99px; }

/* Score ring */
.ring {
  --val: 0;
  --col: var(--accent);
  width: 168px; height: 168px;
  border-radius: 50%;
  background: conic-gradient(var(--col) calc(var(--val) * 1%), var(--line) 0);
  display: grid; place-items: center;
  flex-shrink: 0;
}
.ring-inner {
  width: 132px; height: 132px; border-radius: 50%;
  background: var(--surface);
  display: grid; place-items: center; text-align: center;
}
.ring-num { font-size: 2.8rem; font-weight: 700; line-height: 1; }
.ring-num small { font-size: 1rem; color: var(--muted); font-weight: 400; }
.ring-sm { width: 108px; height: 108px; }
.ring-sm .ring-inner { width: 84px; height: 84px; }
.ring-sm .ring-num { font-size: 1.9rem; }
.score-good { --col: var(--good); }
.score-mid { --col: #b7791f; }
.score-bad { --col: var(--bad); }

/* Results */
.result-head { display: grid; grid-template-columns: auto 1fr; gap: 2rem; align-items: center; }
.result-meta { color: var(--muted); margin: 0; word-break: break-all; }
.badge {
  display: inline-block;
  padding: .2rem .7rem;
  border-radius: 99px;
  font-weight: 700;
  font-size: .85rem;
}
.badge-good { background: var(--good-soft); color: var(--good); }
.badge-mid { background: var(--warn-soft); color: var(--warn); }
.badge-bad { background: var(--bad-soft); color: var(--bad); }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin: 2rem 0; list-style: none; padding: 0; }
.stats li { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 1rem 1.2rem; }
.stats b { display: block; font-size: 1.8rem; line-height: 1.2; }
.stats span { color: var(--muted); font-size: .92rem; }
.actions { display: flex; flex-wrap: wrap; gap: .75rem; margin: 1.5rem 0 0; }
.screenshot { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; box-shadow: var(--shadow); }
.screenshot img { display: block; }

.impact-group { margin-top: 2.5rem; }
.group-title { display: flex; align-items: center; gap: .6rem; font-size: 1.35rem; }
.dot { width: 14px; height: 14px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.dot-critical { background: var(--critical); }
.dot-serious { background: var(--serious); }
.dot-moderate { background: var(--moderate); }
.dot-minor { background: var(--minor); }

.issue {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-bottom: .75rem;
}
.issue summary {
  cursor: pointer;
  list-style: none;
  padding: 1rem 1.2rem;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1rem;
  align-items: center;
}
.issue summary::-webkit-details-marker { display: none; }
.issue-title { font-weight: 700; }
.issue-meta { display: block; color: var(--muted); font-size: .9rem; font-weight: 400; margin-top: .15rem; }
.issue-count { background: var(--bg); border-radius: 99px; padding: .2rem .75rem; font-weight: 700; font-size: .9rem; white-space: nowrap; }
.issue-body { padding: 0 1.2rem 1.2rem; border-top: 1px solid var(--line); }
.issue-body h4 { font-size: 1rem; margin: 1rem 0 .5rem; }
.example { background: var(--bg); border-radius: 8px; padding: .75rem .9rem; margin-bottom: .6rem; font-size: .92rem; }
.example code, .example pre {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .82rem;
  white-space: pre-wrap;
  word-break: break-all;
}
.example pre { margin: .4rem 0 0; background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: .5rem .6rem; }
.example .fix { margin-top: .5rem; white-space: pre-line; color: var(--muted); }

.empty-ok { background: var(--good-soft); color: var(--good); border-radius: 12px; padding: 1.25rem; font-weight: 700; }

.manual-list { columns: 2; column-gap: 2rem; padding-left: 1.2rem; color: var(--muted); }
.manual-list li { break-inside: avoid; margin-bottom: .4rem; }

/* Admin */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
table { border-collapse: collapse; width: 100%; font-size: .92rem; }
th, td { text-align: left; padding: .65rem .8rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: var(--bg); }

.prose h2 { font-size: 1.35rem; margin-top: 2rem; }
.prose p, .prose li { color: #2b303a; }

@media (max-width: 900px) {
  .hero-grid, .law-grid, .cta-band { grid-template-columns: 1fr; }
  .steps { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .result-head { grid-template-columns: 1fr; justify-items: start; }
  .manual-list { columns: 1; }
}
@media (max-width: 560px) {
  .field-row { grid-template-columns: 1fr; }
  .header-cta { font-size: .95rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition: none !important; }
  .spinner { border-top-color: var(--accent); }
}

/* Correzioni suggerite */
.code-label { margin: .7rem 0 0; font-size: .82rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.code-before { color: var(--bad); }
.code-after { color: var(--good); }
.example .pre-after { border-color: var(--good); border-left: 4px solid var(--good); background: #f6fbf8; }
.fix-note { margin: .6rem 0 0; color: var(--ink); }
.ai-tag { display: inline-block; font-size: .78rem; font-weight: 700; background: var(--accent-soft); color: var(--accent); border-radius: 99px; padding: .1rem .55rem; }

/* Area riservata */
.admin-nav { display: flex; gap: 1.25rem; margin-bottom: 1.5rem; border-bottom: 1px solid var(--line); padding-bottom: .75rem; }
.admin-nav a { font-weight: 700; text-decoration: none; color: var(--muted); padding: .25rem 0; }
.admin-nav a[aria-current="page"] { color: var(--ink); border-bottom: 3px solid var(--accent); }
.flash { padding: .75rem 1rem; border-radius: 8px; font-weight: 700; }
.flash-ok { background: var(--good-soft); color: var(--good); }
.flash-error { background: var(--bad-soft); color: var(--bad); }
.section-sub { color: var(--muted); max-width: 70ch; }
.admin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; margin-top: 1.5rem; align-items: start; }
.admin-grid > details > summary { cursor: pointer; }
.code-box, .code-input {
  width: 100%; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85rem;
  border: 2px solid #8b8f99; border-radius: 8px; padding: .6rem; background: var(--bg); color: var(--ink); resize: vertical;
}
.code-input { width: auto; min-width: 0; flex: 1; min-height: 40px; }
.btn-sm { min-height: 40px; padding: .45rem .9rem; font-size: .92rem; margin-top: .5rem; }
.btn-danger { background: var(--bad); border-color: var(--bad); }
.btn-danger:hover { background: #8f1c13; border-color: #8f1c13; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: .5rem 1rem; align-items: center; }
.kv dt { font-weight: 700; }
.kv dd { margin: 0; display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.kv dd .btn-sm { margin-top: 0; }
.scan-list { list-style: none; padding: 0; margin: .5rem 0 0; }
.scan-list li { padding: .5rem 0; border-bottom: 1px solid var(--line); word-break: break-all; }
.text-bad { color: var(--bad); }
.bulk-bar { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; margin: 1rem 0; position: sticky; top: 0; background: var(--bg); padding: .5rem 0; z-index: 2; }
.bulk-bar .btn-sm { margin-top: 0; }
.check-inline { display: inline-flex; gap: .4rem; align-items: center; font-weight: 400; }
.check-inline input { width: 20px; height: 20px; accent-color: var(--accent); }
.fix-row { display: grid; grid-template-columns: auto 1fr auto; gap: 1rem; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 1rem 1.2rem; margin: 0 0 .75rem; }
.fix-select input { width: 22px; height: 22px; margin-top: .2rem; accent-color: var(--accent); }
.fix-title { font-weight: 700; margin: 0; }
.fix-main .small { margin: .2rem 0 .5rem; word-break: break-all; }
.mini-pre { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .8rem; background: var(--bg); border-radius: 6px; padding: .5rem .6rem; white-space: pre-wrap; word-break: break-all; margin: 0 0 .75rem; max-height: 7.5rem; overflow: auto; }
.fix-edit { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; }
.fix-edit > label:first-child { font-weight: 700; flex-basis: 100%; }
.fix-edit input[type="text"] { flex: 1; min-width: 220px; min-height: 42px; }
.fix-actions { display: flex; flex-direction: column; gap: .4rem; }
.fix-actions .btn-sm { margin-top: 0; }
@media (max-width: 900px) {
  .admin-grid { grid-template-columns: 1fr; }
  .fix-row { grid-template-columns: auto 1fr; }
  .fix-actions { grid-column: 1 / -1; flex-direction: row; }
}
