:root {
  --color-primary: #20404b;
  --color-primary-dark: #152e36;
  --color-muted: #72868d;
  --color-bg: #f5f7f7;
  --color-surface: #ffffff;
  --color-border: #e3e7e8;
  --color-text: #1f2e34;
  --color-text-soft: #55666d;
  --color-danger-bg: #fdecea;
  --color-danger-text: #611a15;
  --color-warn-bg: #fdf3e2;
  --color-warn-text: #7a5510;
  --color-success-bg: #e6f4ea;
  --color-success-text: #1e7e34;
  --color-admin-bg: #e8f0fe;
  --color-admin-text: #1a4d99;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(20, 40, 46, 0.07), 0 1px 2px rgba(20, 40, 46, 0.04);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 32px 16px;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

h1 {
  font-size: 1.4em;
  margin: 0 0 20px;
  color: var(--color-primary);
  font-weight: 600;
}

h2 {
  font-size: 1.05em;
  margin: 28px 0 12px;
  color: var(--color-primary);
  font-weight: 600;
}

a { color: var(--color-primary); }
a:hover { color: var(--color-primary-dark); }

/* Top navigation */

.topbar {
  max-width: 640px;
  margin: 0 auto 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  row-gap: 8px;
}

.brand { display: inline-flex; align-items: center; }
.brand-logo { height: 46px; width: auto; display: block; }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.lang-switch {
  font-size: 0.92em;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}
.lang-switch a {
  text-decoration: none;
  color: var(--color-text-soft);
  font-weight: 600;
  transition: opacity 0.15s ease, color 0.15s ease;
}
.lang-switch a:hover { opacity: 0.6; }
.lang-switch a.active { color: var(--color-primary); }
.lang-switch .sep { color: var(--color-border); font-weight: 400; }

/* Cambio lingua sulle pagine auth (login/registrati/recupero password), che
   sostituiscono l'intero topbar con solo questo switch (nessun logo/menu). */
.lang-switch-standalone {
  width: 100%;
  max-width: 400px;
  display: flex;
  justify-content: flex-end;
  margin: 0 0 4px;
}

.user-dropdown { position: relative; display: inline-block; }
.user-dropdown summary {
  cursor: pointer;
  list-style: none;
  font-weight: 600;
  color: var(--color-text-soft);
  user-select: none;
  transition: opacity 0.15s ease;
}
.user-dropdown summary::-webkit-details-marker { display: none; }
.user-dropdown summary::after { content: "▾"; margin-left: 4px; font-size: 0.75em; }
.user-dropdown:hover summary,
.user-dropdown[open] summary { opacity: 0.6; }
.user-dropdown .dropdown-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-width: 140px;
  padding: 6px;
  z-index: 20;
  display: flex;
  flex-direction: column;
}
.user-dropdown .dropdown-menu a {
  display: block;
  padding: 8px 10px;
  border-radius: 6px;
  text-decoration: none;
  color: var(--color-text);
  font-weight: 500;
  font-size: 0.92em;
  transition: background 0.15s ease;
}
.user-dropdown .dropdown-menu a:hover { background: var(--color-bg); }

.user-menu {
  font-size: 0.92em;
  color: var(--color-text-soft);
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}
.user-menu a {
  text-decoration: none;
  color: var(--color-text-soft);
  font-weight: 600;
  transition: opacity 0.15s ease, color 0.15s ease;
}
.user-menu a:hover { opacity: 0.6; color: var(--color-text-soft); }
.user-menu .user-menu-name { font-weight: 400; }
.user-menu .sep { color: var(--color-border); font-weight: 400; }

/* Page / card */

.page {
  max-width: 640px;
  margin: 0 auto;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px;
}

body.wide .topbar,
body.wide .page { max-width: 960px; }

/* Auth layout (login page) */

body.auth {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
body.auth .page { width: 100%; max-width: 400px; }
.auth-logo { display: block; height: 150px; width: auto; margin: 0 auto 28px; }

.auth-actions {
  display: flex;
  align-items: center;
  margin-top: 20px;
}
.auth-actions button { margin-top: 0; }
.auth-actions .auth-or {
  flex: 1;
  text-align: center;
  color: var(--color-text-soft);
  font-size: 0.85em;
}
.auth-actions .btn-ghost { margin-top: 0; }

/* Flash messages */

.flash {
  background: var(--color-danger-bg);
  color: var(--color-danger-text);
  padding: 10px 14px;
  border-radius: 6px;
  margin-bottom: 16px;
  font-size: 0.92em;
}

.alert-warn {
  background: var(--color-warn-bg);
  color: var(--color-warn-text);
  padding: 9px 12px;
  border-radius: 6px;
  margin-top: 8px;
  font-size: 0.87em;
}

/* Forms */

label { display: block; margin-top: 14px; font-weight: 600; font-size: 0.9em; color: var(--color-text); }

input[type=text],
input[type=email],
input[type=password],
input[type=number],
input[type=file],
textarea {
  width: 100%;
  padding: 9px 10px;
  margin-top: 5px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 0.95em;
  font-family: inherit;
  color: var(--color-text);
  background: var(--color-surface);
}
textarea { resize: vertical; }
input:focus,
textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(32, 64, 75, 0.12);
}

button {
  margin-top: 20px;
  padding: 10px 20px;
  border: none;
  border-radius: 6px;
  background: var(--color-primary);
  color: #fff;
  font-size: 0.95em;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}
button:hover { background: var(--color-primary-dark); }
button:disabled { background: var(--color-border); color: var(--color-text-soft); cursor: not-allowed; }

.radio-row { margin-top: 14px; }
.radio-row label { display: inline-block; font-weight: 400; margin-right: 20px; }

.consent-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 18px;
  font-weight: 400;
  font-size: 0.87em;
  color: var(--color-text-soft);
}
.consent-row input[type=checkbox] { margin-top: 3px; flex-shrink: 0; }

/* Honeypot anti-bot: campo mai visibile a un utente reale, un bot che
   compila tutti i campi ci casca comunque. */
.hp-field { position: absolute; left: -9999px; top: -9999px; }

.hint { color: var(--color-text-soft); font-size: 0.87em; }

.download-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 20px 0;
}

.download-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 16px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-bg);
}

.download-name {
  font-size: 0.9em;
  color: var(--color-text);
  word-break: break-all;
}

.btn-download {
  flex-shrink: 0;
  padding: 8px 16px;
  border-radius: 6px;
  background: var(--color-primary);
  color: #fff;
  font-weight: 600;
  font-size: 0.87em;
  text-decoration: none;
  white-space: nowrap;
}
.btn-download:hover { background: var(--color-primary-dark); color: #fff; }

.btn-ghost {
  margin-top: 0;
  padding: 9px 18px;
  border: 1.5px solid var(--color-primary);
  border-radius: 6px;
  background: transparent;
  color: var(--color-primary);
  font-size: 0.9em;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.btn-ghost:hover { background: var(--color-primary); color: #fff; }

/* Anteprima 3D della geometria (step 2, on-demand) */

.geometry-preview-box {
  margin-top: 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-bg);
  padding: 16px;
}
.geometry-preview-box[hidden] { display: none; }

.geometry-canvas {
  width: 100%;
  height: 420px;
  border-radius: 8px;
  overflow: hidden;
  background: #f5f7f7;
}
.geometry-canvas canvas { display: block; }

.geometry-preview-status,
.geometry-preview-hint {
  margin: 10px 0 0;
  text-align: center;
}

/* Stepper (timeline avanzamento conversione) */

.stepper {
  display: flex;
  align-items: flex-start;
  margin: 4px 0 32px;
}

.step {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 0 0 auto;
  width: 84px;
}

.step-circle {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.92em;
  border: 2px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text-soft);
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.step.completed .step-circle {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}

.step-circle .step-check,
.step-circle .step-excl,
.step-circle .step-num { display: none; }
.step.completed .step-circle .step-check { display: inline-flex; }
.step.error .step-circle .step-excl { display: inline; }
.step:not(.completed):not(.error) .step-circle .step-num { display: inline; }

.step.active .step-circle {
  border-color: var(--color-primary);
  color: var(--color-primary);
  background: var(--color-surface);
  box-shadow: 0 0 0 4px rgba(32, 64, 75, 0.14);
}

.step.error .step-circle {
  border-color: var(--color-danger-text);
  background: var(--color-danger-bg);
  color: var(--color-danger-text);
}

.step-label {
  margin-top: 9px;
  font-size: 0.74em;
  text-align: center;
  color: var(--color-text-soft);
  font-weight: 600;
  line-height: 1.3;
}

.step.active .step-label,
.step.completed .step-label {
  color: var(--color-text);
}

.step.error .step-label { color: var(--color-danger-text); }

.step.clickable { cursor: pointer; }
.step.clickable:hover .step-circle { box-shadow: 0 0 0 4px rgba(32, 64, 75, 0.14); }
.step.clickable:focus-visible { outline: none; }
.step.clickable:focus-visible .step-circle { box-shadow: 0 0 0 4px rgba(32, 64, 75, 0.28); }
.step.viewing .step-circle { box-shadow: 0 0 0 4px rgba(32, 64, 75, 0.14); }

.step-line {
  flex: 1 1 auto;
  height: 2px;
  min-width: 8px;
  background: var(--color-border);
  margin-top: 18px;
  transition: background 0.25s ease;
}

.step-line.completed { background: var(--color-primary); }

@media (max-width: 420px) {
  .step { width: 62px; }
  .step-circle { width: 30px; height: 30px; font-size: 0.82em; }
  .step-label { font-size: 0.64em; margin-top: 6px; }
  .step-line { margin-top: 14px; }
}

.step-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 20px;
}
.step-actions button { margin-top: 0; }
.step-actions button:last-child { margin-left: auto; }

.btn-next {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.final-actions {
  margin-top: 24px;
  text-align: center;
}

.error-output {
  background: #f6f6f6;
  padding: 14px;
  overflow-x: auto;
  white-space: pre-wrap;
  border-radius: 6px;
  font-size: 0.85em;
}

/* Admin table */

table { width: 100%; border-collapse: collapse; margin-top: 16px; font-size: 0.92em; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--color-border); vertical-align: middle; }
th { color: var(--color-text-soft); font-weight: 600; font-size: 0.85em; text-transform: uppercase; letter-spacing: 0.03em; }

form.inline { display: inline-block; margin: 0 4px 4px 0; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.actions input[type=number] { width: 70px; padding: 5px; margin: 0; }
.actions input[type=password] { width: 130px; padding: 5px; margin: 0; }
.actions button { margin: 0; padding: 5px 10px; font-size: 0.85em; }

.badge { padding: 2px 7px; border-radius: 4px; font-size: 0.76em; margin-left: 6px; font-weight: 600; }
.badge.admin { background: var(--color-admin-bg); color: var(--color-admin-text); }
.badge.inactive { background: var(--color-danger-bg); color: var(--color-danger-text); }
.badge.active { background: var(--color-success-bg); color: var(--color-success-text); }

/* Elenco lavori */

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 4px;
}
.page-header h1 { margin: 0; }
.page-header .btn-download { flex-shrink: 0; }

.job-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 20px 0;
}

.job-row {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-bg);
  transition: box-shadow 0.15s ease, transform 0.15s ease, border-color 0.15s ease;
}
.job-row:not(.expired):hover {
  box-shadow: var(--shadow);
  transform: translateY(-1px);
  border-color: var(--color-primary);
}
.job-row.expired { opacity: 0.55; }

.job-row .stretched-link {
  position: absolute;
  inset: 0;
  z-index: 1;
}

.job-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.job-name {
  font-weight: 600;
  font-size: 0.92em;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 380px;
}

.job-files {
  font-size: 0.8em;
  color: var(--color-text-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 380px;
}

.job-meta { font-size: 0.78em; color: var(--color-text-soft); }

.job-side {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.job-expiry { font-size: 0.76em; color: var(--color-text-soft); white-space: nowrap; }
.job-expiry-gone { color: var(--color-danger-text); }

.job-delete-form {
  position: relative;
  z-index: 2;
  margin: 0;
}

.job-delete {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  margin: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--color-text-soft);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.job-delete:hover { background: var(--color-danger-bg); color: var(--color-danger-text); }

.badge.step2 { background: var(--color-warn-bg); color: var(--color-warn-text); margin-left: 0; }
.badge.done { background: var(--color-success-bg); color: var(--color-success-text); margin-left: 0; }
.badge.error { background: var(--color-danger-bg); color: var(--color-danger-text); margin-left: 0; }
.badge.running { background: var(--color-admin-bg); color: var(--color-admin-text); margin-left: 0; }

@media (max-width: 480px) {
  .job-name, .job-files { max-width: 160px; }
  .job-row { flex-wrap: wrap; }
  .job-side { width: 100%; justify-content: space-between; }
}

fieldset { border: 1px solid var(--color-border); border-radius: var(--radius); margin-top: 16px; padding: 16px; }

/* Box di attesa durante una conversione (inline, nella stessa schermata) */

.conversion-progress-card {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 24px 28px;
  margin-top: 20px;
  text-align: center;
}
.conversion-progress-card[hidden] { display: none; }

.conversion-overlay-title {
  margin: 0 0 18px;
  font-weight: 600;
  color: var(--color-text);
}

.conversion-progress-bar {
  height: 8px;
  border-radius: 4px;
  background: var(--color-border);
  overflow: hidden;
}

.conversion-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--color-primary);
  transition: width 0.4s ease;
}

.conversion-overlay-status {
  margin: 14px 0 0;
  min-height: 1.2em;
  font-size: 0.85em;
  color: var(--color-text-soft);
}
legend { padding: 0 6px; font-weight: 600; color: var(--color-primary); font-size: 0.92em; }

/* Disclaimer beta testing (_beta_modal.html) */

.beta-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(31, 46, 52, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1000;
}
.beta-modal-card {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-width: 480px;
  width: 100%;
  padding: 28px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
}
.beta-modal-card h2 { margin-top: 0; color: var(--color-primary); }
.beta-modal-card ul { padding-left: 20px; margin: 12px 0; }
.beta-modal-card li { margin-bottom: 8px; font-size: 0.93em; }
.beta-modal-card button { width: 100%; }

/* Box "Novità" in fondo alla Dashboard */

.news-box {
  margin-top: 28px;
  padding: 16px 18px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
}
.news-box h2 { margin: 0 0 8px; font-size: 1em; color: var(--color-primary); }
.news-content { white-space: pre-wrap; font-size: 0.92em; color: var(--color-text-soft); }

/* Pagina Guida */

.guide-list { display: flex; flex-direction: column; gap: 10px; margin: 20px 0; }
.guide-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  text-decoration: none;
  color: var(--color-text);
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}
.guide-item:hover { box-shadow: var(--shadow); border-color: var(--color-primary); }
.guide-icon { font-size: 1.6em; }
.guide-text { flex: 1; display: flex; flex-direction: column; }
.guide-name { font-weight: 600; }
.guide-desc { font-size: 0.85em; color: var(--color-text-soft); }
.guide-download { font-weight: 600; color: var(--color-primary); white-space: nowrap; }

/* Step 5 (dati impianti) */

.step5-entry {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 20px;
  padding: 14px 16px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  text-decoration: none;
  color: var(--color-text);
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}
.step5-entry:hover { box-shadow: var(--shadow); border-color: var(--color-primary); }
.step5-entry-text { display: flex; flex-direction: column; gap: 2px; }
.step5-entry-cta { font-weight: 600; color: var(--color-primary); white-space: nowrap; }

.step5-messages {
  margin: 16px 0;
  padding: 4px 0;
  list-style: none;
}
.step5-messages li {
  padding: 9px 12px;
  border-radius: 6px;
  margin-bottom: 6px;
  font-size: 0.87em;
  background: var(--color-warn-bg);
  color: var(--color-warn-text);
}

/* Messaggi per livello (impianti ad aria): ERRORE rosso, AVVISO giallo, il resto neutro */
.step5-messages.by-level li {
  border-left: 3px solid transparent;
  border-radius: 0 6px 6px 0;
}
.step5-messages.by-level li.error {
  background: var(--color-danger-bg);
  color: var(--color-danger-text);
  border-left-color: #c9453a;
}
.step5-messages.by-level li.warning {
  background: var(--color-warn-bg);
  color: var(--color-warn-text);
  border-left-color: #d9a441;
}
.step5-messages.by-level li.info {
  background: var(--color-surface);
  color: var(--color-text-soft);
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--color-border);
}

.service-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--color-admin-bg);
  color: var(--color-admin-text);
  font-size: 0.78em;
  font-weight: 600;
  vertical-align: 1px;
  word-break: normal;
}

/* Step 5 — schemi d'impianto (netlist + validazione) */

.schema-section {
  margin-top: 36px;
  padding-top: 8px;
  border-top: 1px solid var(--color-border);
}
.schema-upload button { margin-top: 12px; }

.schema-card {
  margin-top: 18px;
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-success-text);
  border-radius: var(--radius);
  background: var(--color-surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.schema-card.has-errors { border-left-color: var(--color-danger-text); }

.schema-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 16px;
  border-bottom: 1px solid var(--color-border);
}
.schema-card-title { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.schema-name { font-weight: 600; word-break: break-all; }
.schema-status { font-size: 0.82em; color: var(--color-text-soft); }
.schema-card.is-valid .schema-status { color: var(--color-success-text); }
.schema-card.has-errors .schema-status { color: var(--color-danger-text); }

.schema-counts { display: flex; gap: 6px; flex-wrap: wrap; }
.schema-pill {
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.76em;
  font-weight: 600;
  white-space: nowrap;
}
.schema-pill.error { background: var(--color-danger-bg); color: var(--color-danger-text); }
.schema-pill.warning { background: var(--color-warn-bg); color: var(--color-warn-text); }
.schema-pill.info { background: var(--color-admin-bg); color: var(--color-admin-text); }
.schema-pill.zero { background: var(--color-bg); color: var(--color-muted); }

.schema-msgs { margin: 12px 16px 0; padding: 10px 12px; border-radius: 6px; font-size: 0.86em; }
.schema-msgs.error { background: var(--color-danger-bg); color: var(--color-danger-text); }
.schema-msgs.warning { background: var(--color-warn-bg); color: var(--color-warn-text); }
.schema-msgs.info { background: var(--color-admin-bg); color: var(--color-admin-text); }
.schema-msgs-title {
  font-size: 0.78em;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}
.schema-msgs ul { margin: 0; padding-left: 18px; }
.schema-msgs li + li { margin-top: 3px; }
.schema-xy { opacity: 0.6; font-size: 0.9em; white-space: nowrap; }

.schema-loop {
  margin: 14px 16px 0;
  padding: 12px 14px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-bg);
  font-size: 0.87em;
}
.schema-loop-title { font-weight: 600; color: var(--color-primary); word-break: break-all; }
.schema-kind {
  display: inline-block;
  margin-right: 4px;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--color-primary);
  color: #fff;
  font-size: 0.75em;
  font-weight: 600;
  vertical-align: 1px;
}
.schema-branch,
.schema-demand {
  margin-top: 10px;
  padding-left: 12px;
  border-left: 2px solid var(--color-border);
  word-break: break-word;
}
.schema-branch-head { font-weight: 600; }
.schema-demand .schema-kind { background: var(--color-muted); }
.schema-nodes { color: var(--color-text-soft); font-size: 0.95em; margin-top: 2px; }
.schema-arrow { color: var(--color-primary); font-weight: 700; padding: 0 2px; }

.schema-seq { margin: 8px 0 0; padding: 0; list-style: none; counter-reset: seq; }
.schema-seq li {
  counter-increment: seq;
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  padding: 3px 0;
}
.schema-seq li::before {
  content: counter(seq);
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  line-height: 20px;
  border-radius: 50%;
  background: var(--color-surface);
  border: 1.5px solid var(--color-primary);
  color: var(--color-primary);
  font-size: 0.75em;
  font-weight: 700;
  text-align: center;
}
.schema-comp { font-weight: 500; }
.schema-seq code { font-size: 0.85em; color: var(--color-text-soft); }
.schema-meta { margin-top: 10px; color: var(--color-text-soft); font-size: 0.95em; }

.schema-actions { display: flex; gap: 10px; flex-wrap: wrap; padding: 14px 16px; }
.schema-actions .btn-ghost { text-decoration: none; font-size: 0.85em; padding: 7px 14px; }

/* Stepper: step raggiungibili con un link (pagina step 5 -> step 4) */
a.step { text-decoration: none; color: inherit; }
a.step:focus-visible { outline: none; }
a.step:focus-visible .step-circle { box-shadow: 0 0 0 4px rgba(32, 64, 75, 0.28); }

/* Step 5 — riepilogo clima di progetto */

.climate-card {
  margin: 4px 0 20px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.climate-head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 10px;
  padding: 12px 16px;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
}
.climate-label {
  font-size: 0.72em;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-muted);
}
.climate-epw { font-weight: 600; color: var(--color-primary); word-break: break-all; }
.climate-city { font-size: 0.87em; color: var(--color-text-soft); }

.climate-grid {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0;
  margin: 0;
  padding: 6px 16px;
  font-size: 0.9em;
}
.climate-grid dt,
.climate-grid dd {
  margin: 0;
  padding: 8px 0;
  border-bottom: 1px solid var(--color-border);
}
.climate-grid dt:last-of-type,
.climate-grid dd:last-of-type { border-bottom: none; }
.climate-grid dt { padding-right: 20px; color: var(--color-text-soft); }
.climate-grid dd strong { font-weight: 600; color: var(--color-text); }
.climate-sep { margin: 0 7px; color: var(--color-muted); }
.climate-zone {
  display: inline-block;
  min-width: 26px;
  padding: 1px 7px;
  border-radius: 4px;
  background: var(--color-primary);
  color: #fff;
  font-weight: 700;
  font-size: 0.9em;
  text-align: center;
}
.climate-note {
  margin: 0;
  padding: 10px 16px 12px;
  font-size: 0.78em;
  color: var(--color-muted);
  border-top: 1px solid var(--color-border);
}

@media (max-width: 480px) {
  .climate-grid { grid-template-columns: 1fr; }
  .climate-grid dt { padding: 8px 0 0; border-bottom: none; font-size: 0.85em; }
  .climate-grid dd { padding-top: 2px; }
}
@media (max-width: 420px) {
  .stepper .step { width: 56px; }
}

/* Step 5 — avviso critico (AVVISO CRITICO: box in cima, non blocca il giro) */
.critical-box {
  margin: 16px 0;
  padding: 12px 16px 12px 14px;
  border: 1px solid #f1b8b2;
  border-left: 4px solid #c9453a;
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--color-danger-bg);
  color: var(--color-danger-text);
}
.critical-title {
  font-size: 0.75em;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #a3322a;
  margin-bottom: 4px;
}
.critical-box ul { margin: 0; padding-left: 18px; font-size: 0.9em; line-height: 1.45; }
.critical-box li + li { margin-top: 6px; }
.critical-note { margin: 8px 0 0; font-size: 0.78em; opacity: 0.8; }

/* Step 5 — bilancio d'aria di progetto */
.balance-section {
  margin-top: 36px;
  padding-top: 8px;
  border-top: 1px solid var(--color-border);
}
.balance-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.balance-head h2 { margin-right: auto; }
.balance-badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.75em;
  font-weight: 600;
  vertical-align: 1px;
}
.balance-badge.preview { background: var(--color-admin-bg); color: var(--color-admin-text); word-break: break-all; }
.balance-badge.critical { background: var(--color-danger-bg); color: #a3322a; }

.balance-status {
  margin: 6px 0 0;
  padding: 7px 10px;
  border-radius: 6px;
  font-size: 0.84em;
  background: var(--color-bg);
  color: var(--color-text-soft);
}
.balance-status.busy { color: var(--color-muted); }
.balance-status.ok { background: var(--color-success-bg); color: var(--color-success-text); }
.balance-status.warning { background: var(--color-warn-bg); color: var(--color-warn-text); }
.balance-status.error { background: var(--color-danger-bg); color: var(--color-danger-text); }

.ahu-summary {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 12px;
  margin: 14px 0 4px;
}
.ahu-card {
  border: 1px solid var(--color-border);
  border-top: 3px solid var(--color-primary);
  border-radius: var(--radius);
  background: var(--color-surface);
  box-shadow: var(--shadow);
  padding: 10px 14px 12px;
}
.ahu-card.excess { border-top-color: #c9453a; }
.ahu-card-title { font-weight: 700; margin-bottom: 6px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ahu-card dl {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 3px 12px;
  margin: 0;
  font-size: 0.84em;
}
.ahu-card dt { color: var(--color-text-soft); }
.ahu-card dd { margin: 0; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.ahu-card dd.bad { color: #a3322a; }
.ahu-summary .balance-unit { grid-column: 1 / -1; margin: 0; }

.balance-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 16px 0 8px; font-size: 0.78em; }
.balance-legend .chip { padding: 2px 9px; border-radius: 4px; color: var(--color-text); }
.chip.deficit { background: #fff2cc; }
.chip.surplus { background: #e4dfec; }
.chip.error { background: #ffc7ce; }
.balance-count { margin-left: auto; font-weight: 600; color: #a3322a; }

.balance-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  box-shadow: var(--shadow);
}
.balance-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78em;
  font-variant-numeric: tabular-nums;
}
.balance-table th {
  padding: 8px 6px;
  background: var(--color-bg);
  color: var(--color-text-soft);
  font-weight: 600;
  text-align: right;
  vertical-align: bottom;
  line-height: 1.2;
  min-width: 52px;
  border-bottom: 1px solid var(--color-border);
}
.balance-table td {
  padding: 6px;
  text-align: right;
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}
.balance-table tbody tr:last-child td { border-bottom: none; }
.balance-table .zone { text-align: left; font-weight: 600; position: sticky; left: 0; background: inherit; }
.balance-table th.zone { background: var(--color-bg); }
.balance-table td.zone { background: var(--color-surface); }
.balance-table .trf { text-align: left; white-space: normal; min-width: 96px; }
.balance-table td.trf { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.95em; }
.balance-table tr.deficit td.sbil, .balance-table tr.deficit td.inf { background: #fff2cc; }
.balance-table tr.surplus td.sbil, .balance-table tr.surplus td.exf { background: #e4dfec; }
.balance-table td.trf.error { background: #ffc7ce; color: var(--color-danger-text); }
.balance-table tr.has-error td { border-bottom-color: transparent; }
.balance-table tr.error-row td {
  padding-top: 0;
  text-align: left;
  white-space: normal;
  color: var(--color-danger-text);
}
.balance-table .dflt { color: var(--color-muted); margin-left: 1px; }
.balance-unit { margin: 6px 2px 0; font-size: 0.75em; color: var(--color-muted); }

.balance-cols { display: grid; grid-template-columns: 1fr; gap: 14px; margin-top: 18px; }
.balance-block {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  padding: 10px 14px 12px;
}
.balance-block h3 { margin: 0 0 8px; font-size: 0.95em; }
.balance-sub { font-weight: 400; font-size: 0.85em; color: var(--color-muted); margin-left: 4px; }
.transfer-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 4px 16px;
  font-size: 0.85em;
  font-variant-numeric: tabular-nums;
}
.transfer-list li { display: flex; align-items: baseline; gap: 6px; padding: 3px 0; border-bottom: 1px dashed var(--color-border); }
.transfer-list .tz { font-weight: 600; }
.transfer-list .tarrow { color: var(--color-muted); }
.transfer-list .tq { margin-left: auto; }
.transfer-list .tauto {
  font-size: 0.78em;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--color-admin-bg);
  color: var(--color-admin-text);
}

/* Stepper a 6 step (impianti ad aria): stesse proporzioni, piu' stretto su mobile */
.stepper-6 .step { width: 78px; }
@media (max-width: 560px) {
  .stepper-6 .step { width: 54px; }
  .stepper-6 .step-circle { width: 30px; height: 30px; font-size: 0.82em; }
  .stepper-6 .step-label { font-size: 0.64em; margin-top: 6px; }
  .stepper-6 .step-line { margin-top: 14px; min-width: 4px; }
}
@media (max-width: 420px) {
  .stepper-6 .step { width: 46px; }
  .stepper-6 .step-circle { width: 26px; height: 26px; font-size: 0.76em; }
  .stepper-6 .step-label { font-size: 0.58em; }
  .stepper-6 .step-line { margin-top: 12px; }
}

/* Step 5 con impianti ad aria: sezioni, pulsanti "Mostra ...", Genera IDF */
.round-section {
  margin-top: 36px;
  padding-top: 8px;
  border-top: 1px solid var(--color-border);
}
.balance-section .balance-block { margin-top: 16px; }
.balance-section .balance-status { margin: 12px 0 0; }

.reveal { margin-top: 14px; }
.reveal > summary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border: 1.5px solid var(--color-primary);
  border-radius: 6px;
  color: var(--color-primary);
  font-size: 0.87em;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  user-select: none;
  transition: background 0.15s ease, color 0.15s ease;
}
.reveal > summary::-webkit-details-marker { display: none; }
.reveal > summary::after { content: "▾"; font-size: 0.85em; transition: transform 0.15s ease; }
.reveal[open] > summary::after { transform: rotate(180deg); }
.reveal > summary:hover { background: var(--color-primary); color: #fff; }
.reveal > summary:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(32, 64, 75, 0.2); }
.reveal .reveal-close { display: none; }
.reveal[open] .reveal-open { display: none; }
.reveal[open] .reveal-close { display: inline; }
.reveal-count {
  min-width: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--color-admin-bg);
  color: var(--color-admin-text);
  font-size: 0.85em;
  text-align: center;
}
.reveal > summary:hover .reveal-count { background: rgba(255, 255, 255, 0.2); color: #fff; }
.reveal[open] > summary { margin-bottom: 10px; }
.warn-reveal > summary { border-color: #d9a441; color: var(--color-warn-text); }
.warn-reveal > summary:hover { background: var(--color-warn-bg); color: var(--color-warn-text); }
.warn-reveal > summary:hover .reveal-count { background: var(--color-admin-bg); color: var(--color-admin-text); }
.warn-reveal .step5-messages { margin: 0; }

.round-messages {
  margin-top: 36px;
  padding-top: 8px;
  border-top: 1px solid var(--color-border);
}
.round-messages .critical-box { margin-top: 12px; }
.msg-tag {
  display: inline-block;
  margin-right: 8px;
  padding: 0 7px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid #f1b8b2;
  color: #a3322a;
  font-size: 0.75em;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  vertical-align: 1px;
}
.msg-tag.error { background: #c9453a; border-color: #c9453a; color: #fff; }

.generate-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 36px;
  padding: 16px 18px;
  border: 1px solid var(--color-primary);
  border-radius: var(--radius);
  background: var(--color-bg);
}
.generate-text { display: flex; flex-direction: column; gap: 3px; }
.generate-card button { margin-top: 0; flex-shrink: 0; }
@media (max-width: 480px) {
  .generate-card { flex-direction: column; align-items: stretch; }
}

