:root {
  --ink: #1b2730;
  --muted: #5f6f7a;
  --line: #d8e0e6;
  --paper: #f7f9fb;
  --surface: #ffffff;
  --brand: #006b62;
  --brand-dark: #094943;
  --accent: #b94023;
  --blue: #315f8a;
  --ok: #22764f;
  --warn: #9a5a13;
  --shadow: 0 18px 45px rgba(27, 39, 48, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  color: var(--ink);
  background: var(--paper);
  font-family: Arial, Helvetica, sans-serif;
}

body {
  margin: 0;
  min-width: 320px;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.app-header {
  background: linear-gradient(135deg, #eef5f4 0%, #ffffff 54%, #f2f6f8 100%);
  border-bottom: 1px solid var(--line);
  padding: 22px clamp(18px, 4vw, 56px) 34px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--brand-dark);
  font-size: 0.92rem;
  font-weight: 700;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 34px;
  border-radius: 4px;
  color: #fff;
  background: var(--brand-dark);
  letter-spacing: 0;
}

.header-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 420px);
  gap: clamp(22px, 5vw, 72px);
  align-items: end;
  max-width: 1240px;
  margin: 54px auto 0;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--brand);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 820px;
  margin-bottom: 16px;
  font-size: clamp(2.15rem, 6vw, 4.75rem);
  line-height: 0.98;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 1.35rem;
}

h3 {
  font-size: 1.05rem;
}

.lead {
  max-width: 760px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: clamp(1.02rem, 1.8vw, 1.25rem);
  line-height: 1.55;
}

.notice {
  border-left: 4px solid var(--accent);
  padding: 16px 18px;
  background: #fff8f5;
  color: #5d2f20;
  box-shadow: var(--shadow);
}

.notice strong,
.notice span {
  display: block;
}

.notice span {
  margin-top: 8px;
  line-height: 1.45;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 22px;
  max-width: 1240px;
  margin: 0 auto;
  padding: 26px clamp(14px, 3vw, 28px) 54px;
}

.wizard,
.summary,
.results,
.feedback {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.wizard,
.results,
.feedback {
  padding: clamp(18px, 3vw, 28px);
}

.summary {
  align-self: start;
  padding: 20px;
}

.section-title {
  margin-bottom: 18px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.field {
  display: grid;
  gap: 7px;
}

.field.wide {
  grid-column: 1 / -1;
}

.field span,
.filters span {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

input[type="text"],
input[type="search"],
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  background: #fff;
  color: var(--ink);
}

.subtle-field {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

textarea {
  resize: vertical;
}

fieldset {
  margin: 22px 0 0;
  border: 0;
  padding: 0;
}

legend {
  margin-bottom: 10px;
  font-weight: 800;
}

.choice-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
}

.choice-grid.compact {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.choice {
  display: flex;
  min-height: 46px;
  align-items: center;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  background: #fbfcfd;
  cursor: pointer;
}

.choice:has(input:checked) {
  border-color: var(--brand);
  background: #eef8f6;
}

.choice input {
  width: 18px;
  height: 18px;
  accent-color: var(--brand);
}

.button-link {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  border: 1px solid #084f49;
  border-radius: 6px;
  padding: 10px 14px;
  background: var(--brand);
  color: #fff;
  font-weight: 800;
  text-decoration: none;
}

.button-link:hover {
  background: var(--brand-dark);
}

.choice span {
  overflow-wrap: anywhere;
}

.atomic-section legend {
  font-size: 1.15rem;
}

.search-field {
  margin-bottom: 14px;
}

.atomic-groups {
  display: grid;
  gap: 12px;
}

.atomic-group {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  overflow: hidden;
}

.atomic-group summary {
  display: flex;
  min-height: 48px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  color: var(--brand-dark);
  font-weight: 900;
  cursor: pointer;
}

.atomic-group summary::-webkit-details-marker {
  display: none;
}

.atomic-group summary::marker {
  content: "";
}

.summary-label {
  min-width: 0;
  overflow-wrap: anywhere;
}

.summary-meta {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
}

.summary-count {
  display: inline-grid;
  min-width: 26px;
  height: 26px;
  place-items: center;
  border-radius: 999px;
  background: #e4efed;
  color: var(--brand-dark);
  font-size: 0.8rem;
}

.summary-toggle {
  width: 9px;
  height: 9px;
  border-right: 2px solid var(--brand-dark);
  border-bottom: 2px solid var(--brand-dark);
  transform: rotate(45deg);
  transition: transform 0.18s ease;
}

.atomic-group[open] .summary-toggle {
  transform: rotate(225deg);
}

.atomic-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  border-top: 1px solid var(--line);
  padding: 12px;
}

.atomic-card {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  gap: 10px;
  min-height: 86px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
  cursor: pointer;
}

.atomic-card:has(input:checked) {
  border-color: var(--brand);
  background: #eef8f6;
}

.atomic-card input {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: var(--brand);
}

.atomic-card strong,
.atomic-card small {
  display: block;
}

.atomic-card strong {
  line-height: 1.25;
}

.atomic-card small {
  margin-top: 5px;
  color: var(--muted);
  line-height: 1.35;
}

.case-missing {
  margin-top: 16px;
  border: 1px solid #d7c3b8;
  border-radius: 8px;
  padding: 16px;
  background: #fff8f5;
}

.case-missing h3 {
  margin-bottom: 8px;
  color: #5d2f20;
}

.case-missing p,
.helper {
  color: var(--muted);
  line-height: 1.5;
}

.dynamic-wrap {
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.dynamic-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.actions,
.tools {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.actions {
  margin-top: 24px;
}

button,
.cta-report a {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 14px;
  background: #fff;
  color: var(--ink);
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}

button:hover,
.cta-report a:hover {
  border-color: var(--brand);
}

button.primary {
  border-color: var(--brand-dark);
  background: var(--brand-dark);
  color: #fff;
}

.signal-list {
  display: grid;
  gap: 10px;
  min-height: 180px;
}

.signal {
  border-left: 3px solid var(--blue);
  padding: 8px 10px;
  background: #f3f7fb;
  font-size: 0.92rem;
  line-height: 1.35;
}

.scorebox {
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.scorebox span {
  display: block;
  color: var(--brand-dark);
  font-size: 2rem;
  font-weight: 900;
}

.scorebox p {
  margin-bottom: 9px;
  color: var(--muted);
}

progress {
  width: 100%;
  height: 10px;
  accent-color: var(--brand);
}

.results,
.feedback {
  grid-column: 1 / -1;
}

.results-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: start;
}

.path-id-header {
  margin-top: 8px;
}

.filters {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 4px 0 22px;
}

.filters label {
  display: grid;
  gap: 7px;
}

.report-intro {
  margin-bottom: 16px;
  border: 1px solid #e7d2c8;
  border-radius: 8px;
  padding: 14px;
  background: #fff8f5;
  color: #533225;
  line-height: 1.5;
}

.report-meta {
  display: grid;
  gap: 12px;
  margin-bottom: 20px;
}

.path-id-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid #c8dce0;
  border-radius: 8px;
  padding: 10px 12px;
  background: #f5fbfa;
}

.path-id-card span {
  display: block;
  color: var(--brand-dark);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.path-id-card strong {
  display: block;
  margin-top: 2px;
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 1.05rem;
  letter-spacing: 0.03em;
  overflow-wrap: anywhere;
}

.path-id-card small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.35;
}

.copy-path-id {
  min-height: 34px;
  padding: 7px 10px;
  white-space: nowrap;
}

.meta-block {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfd;
}

.meta-block h3 {
  margin-bottom: 10px;
}

.meta-block ul {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
  line-height: 1.5;
}

.meta-block p {
  margin-bottom: 8px;
  color: var(--muted);
  line-height: 1.5;
}

.compact-report {
  background: #f7faf9;
}

.compact-report p {
  margin-bottom: 6px;
}

.compact-report p:last-child {
  margin-bottom: 0;
}

.compact-disclaimer {
  font-size: 0.9rem;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.meta-grid div {
  border-left: 3px solid var(--brand);
  padding: 8px 10px;
  background: #fff;
}

.meta-grid span,
.meta-grid strong {
  display: block;
}

.meta-grid span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.meta-grid strong {
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.case-note {
  margin-top: 10px;
  border-left: 3px solid var(--accent);
  padding: 9px 10px;
  background: #fff;
  color: #5d2f20;
  line-height: 1.45;
}

.checklist-output {
  display: grid;
  gap: 18px;
}

.phase-block {
  border-top: 3px solid var(--brand);
  padding-top: 12px;
}

.phase-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  margin-bottom: 12px;
}

.phase-title span {
  color: var(--muted);
  font-size: 0.9rem;
}

.item-list {
  display: grid;
  gap: 10px;
}

.item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
}

.compact-item {
  padding: 12px;
}

.item-head {
  display: block;
}

.item h4 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.item p {
  margin-bottom: 8px;
  color: var(--muted);
  line-height: 1.45;
}

.compact-item p {
  margin-bottom: 8px;
  font-size: 0.93rem;
}

.figure-line {
  margin-top: 8px;
  margin-bottom: 0;
}

.available-line {
  border-left: 3px solid var(--ok);
  padding: 7px 9px;
  background: #f0f8f3;
  color: #245c42;
}

.fascicle-list {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.fascicle-list h5 {
  margin: 0 0 10px;
  font-size: 0.95rem;
}

.fascicle-path {
  margin-top: 10px;
}

.fascicle-title {
  display: grid;
  gap: 3px;
  margin-bottom: 8px;
}

.fascicle-title span,
.doc-meta {
  color: var(--muted);
  font-size: 0.82rem;
}

.fascicle-path ul {
  display: grid;
  gap: 7px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.fascicle-path li {
  display: grid;
  gap: 3px;
  padding: 8px 10px;
  border: 1px solid #dbe5ea;
  border-radius: 6px;
  background: #fbfcfd;
}

.doc-title {
  color: var(--text);
  font-weight: 700;
}

.role-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px 12px;
  margin: 10px 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.35;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.badge {
  border-radius: 999px;
  padding: 4px 8px;
  background: #eef3f6;
  color: #324b5b;
  font-size: 0.76rem;
  font-weight: 800;
}

.badge.essenziale {
  background: #e9f6ef;
  color: var(--ok);
}

.badge.eventuale {
  background: #fff1df;
  color: var(--warn);
}

.service-badge {
  border: 1px solid #b9d9d4;
  background: #e7f5f2;
  color: var(--brand-dark);
  text-decoration: none;
}

.service-badge:hover {
  background: #d7ede8;
}

.prudence {
  margin-top: 10px;
  border-left: 3px solid var(--accent);
  padding: 8px 10px;
  background: #fff8f5;
  color: #633021;
  font-size: 0.9rem;
}

.item select {
  min-height: 38px;
}

.cta-report {
  margin-top: 24px;
  border: 1px solid #c8dad7;
  border-radius: 8px;
  padding: 18px;
  background: #f2f8f7;
}

.cta-report p {
  color: var(--muted);
  line-height: 1.5;
}

.form-status {
  min-height: 22px;
  margin: 10px 0 0;
  color: var(--muted);
}

.empty {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 20px;
  color: var(--muted);
  background: #fbfcfd;
}

@media (max-width: 980px) {
  .header-grid,
  .layout {
    grid-template-columns: 1fr;
  }

  .summary {
    position: static;
  }

  .choice-grid,
  .choice-grid.compact {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dynamic-grid,
  .meta-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .app-header {
    padding-inline: 14px;
  }

  .form-grid,
  .filters,
  .choice-grid,
  .choice-grid.compact,
  .atomic-grid,
  .dynamic-grid,
  .meta-grid,
  .role-grid,
  .item-head {
    grid-template-columns: 1fr;
  }

  .results-head,
  .phase-title {
    display: block;
  }

  .tools {
    margin-top: 12px;
  }
}

@media print {
  @page {
    size: A4;
    margin: 14mm 13mm 14mm 13mm;
  }

  .app-header,
  .wizard,
  .summary,
  .feedback,
  .filters,
  .tools,
  .copy-path-id {
    display: none !important;
  }

  body {
    width: auto;
    min-width: 0;
    margin: 0;
    background: #fff;
    color: #1b2730;
    overflow: visible;
  }

  .layout {
    display: block;
    width: auto;
    max-width: none;
    margin: 0;
    padding: 0;
  }

  .results {
    display: block;
    width: auto;
    max-width: none;
    margin: 0;
    padding: 0 4mm 0 0;
    border: 0;
    box-shadow: none;
    overflow: visible;
  }

  .report-intro,
  .path-id-card,
  .meta-block,
  .phase-block,
  .item,
  .cta-report {
    max-width: 100%;
    overflow: visible;
  }

  .item {
    width: 100%;
    margin-right: 0;
    padding: 10px 12px;
    border-radius: 6px;
  }

  .item h4,
  .item p,
  .figure-line,
  .available-line,
  .badge,
  .phase-title {
    overflow-wrap: anywhere;
    word-break: normal;
  }

  .phase-title {
    padding-right: 2mm;
  }

  .badges {
    max-width: 100%;
  }

  .item,
  .report-intro,
  .cta-report {
    break-inside: avoid;
  }
}
