/* ========================================================================
   IDEE AI — app.css   ·   INDICE
   ========================================================================
   §1  FONDAMENTA            variabili :root, reset, elementi base
   §2  BASE                  Tavolo / Archivio / Landing (1º layer, componenti misti)
   §3  RESPONSIVE/OVERRIDE   @media + passaggi 'final override' mobile
   §4  NAVIGAZIONE/PWA       work-menu, mobile-app-bar, selettore modello
   §5  TEMA idea-first       2º :root, ::placeholder, idea-hero
   §6  PAGINE Processo/Agenti
   §7  TEMA workspace        grande layer override (testo, bottoni, focus, dossier…)
   §8  PAGINE SPECIFICHE     motori AI, modalità Semplice/Advanced, config/run, vista run
   ------------------------------------------------------------------------
   NB: organizzato per 'passaggi'/layer, non per componente; ogni sezione può
       avere le proprie @media. Dedup verificato (0-diff a 3 viewport): ogni
       (selettore, proprietà, media) ha UNA sola dichiarazione.
   ======================================================================== */

/* ========================================================================
   §1 · FONDAMENTA — variabili, reset, elementi base
   ======================================================================== */
:root {
  --bg: #ffffff;
  --rail: #ffffff;
  --rail-soft: #f7f7f5;
  --surface: #ffffff;
  --surface-muted: #f5f5f2;
  --text: #111312;
  --muted: #4a4f47;
  --border: #d7d8d2;
  --accent: #e3f3eb;
  --accent-strong: #176b56;
  --coral: #f4e1dc;
  --coral-red: #d85a46;
  --blue-strong: #3d6fe0;
  --blue: #e6ebfb;
  --warning: #f7ecd0;
  --danger: #b6453c;
  --shadow: 0 14px 38px rgba(18, 24, 20, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow: hidden;
  letter-spacing: 0;
}

button,
textarea,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

/* ========================================================================
   §2 · BASE — Tavolo / Archivio / Landing  (primo layer; componenti misti, usa Cmd+F)
   ======================================================================== */

.app-shell {
  display: grid;
  grid-template-columns: 292px minmax(500px, 1fr) 332px;
  height: 100vh;
  background: #ffffff;
}

.left-rail,
.workbench {
  min-width: 0;
}

.left-rail {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  padding: 18px 16px;
  color: var(--text);
  background: #fbfbfa;
  border-right: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 7px;
  color: #ffffff;
  background: var(--text);
  border: 1px solid var(--text);
  font-weight: 760;
}

.brand h1,
.brand p,
.topbar h2,
.topbar p {
  margin: 0;
}

.brand h1 {
  font-size: 16px;
  line-height: 1.1;
}

.brand p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.rail-section {
  display: grid;
  gap: 10px;
}

.agents-section {
  min-height: auto;
}

.agents-section .agent-list {
  max-height: none;
  overflow: visible;
  padding-right: 4px;
}

.agents-section .agent-list::-webkit-scrollbar,
.timeline::-webkit-scrollbar,
.left-rail::-webkit-scrollbar {
  width: 8px;
}

.agents-section .agent-list::-webkit-scrollbar-thumb,
.timeline::-webkit-scrollbar-thumb,
.left-rail::-webkit-scrollbar-thumb {
  background: rgba(135, 145, 131, 0.35);
  border-radius: 999px;
}

.agents-section .agent-list::-webkit-scrollbar-track,
.timeline::-webkit-scrollbar-track,
.left-rail::-webkit-scrollbar-track {
  background: transparent;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  text-transform: uppercase;
}

.section-heading small {
  color: var(--muted);
  font-size: 11px;
}

textarea {
  width: 100%;
  resize: vertical;
  outline: none;
}

.preset-list,
.agent-list {
  display: grid;
  gap: 8px;
}

.preset-list {
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.preset-button {
  width: 100%;
  display: flex;
  align-items: center;
  min-height: 0;
  padding: 9px 10px;
  text-align: left;
  color: var(--text);
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.preset-button strong {
  display: block;
  font-size: 12px;
  font-weight: 680;
}

.preset-button span {
  display: none;
}

.preset-button.active {
  background: var(--accent);
  border-color: #b8d6c9;
  box-shadow: none;
}

.agent-row {
  display: grid;
  grid-template-columns: 1fr 94px;
  gap: 8px;
  align-items: center;
  min-height: 29px;
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
}

.agent-meta strong {
  display: block;
  color: var(--text);
  font-size: 12px;
  font-weight: 680;
  line-height: 1.2;
}

.agent-meta span {
  display: none;
}

.state-toggle {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
  padding: 2px;
  background: #efefeb;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.state-toggle button {
  height: 20px;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  font-size: 9px;
  font-weight: 680;
  cursor: pointer;
}

.state-toggle button.active[data-state="on"] {
  color: var(--accent-strong);
  background: #dcefe7;
}

.state-toggle button.active[data-state="auto"] {
  color: #7a5b16;
  background: var(--warning);
}

.state-toggle button.active[data-state="off"] {
  color: #8a3a33;
  background: var(--coral);
}

.state-toggle.locked {
  opacity: 0.65;
}

.range-row {
  display: grid;
  gap: 10px;
  align-items: center;
  color: var(--text);
}

.range-row b {
  color: var(--muted);
  font-style: normal;
  text-align: right;
}

.launch-button {
  margin-top: auto;
}

.launch-button:disabled {
  cursor: wait;
  opacity: 0.7;
}

.workbench {
  display: grid;
  grid-template-rows: auto auto auto 1fr auto;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: space-between;
}

.workspace-label {
  text-transform: uppercase;
}

.topbar h2 {
  margin-top: 4px;
}

.run-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #99a096;
}

.status-dot.failed {
  background: var(--danger);
}

.focus-kicker {
  text-transform: uppercase;
}

.timeline {
  display: grid;
  align-content: start;
  gap: 10px;
  overflow-y: auto;
  padding-right: 4px;
}

.timeline-empty {
  margin: 44px auto;
  max-width: 440px;
  color: var(--muted);
  text-align: center;
  line-height: 1.5;
}

.event-row {
  display: grid;
  align-items: start;
}

.event-row time {
  color: var(--muted);
  font-size: 11px;
}

.event-row h4 {
  margin: 0 0 5px;
  font-size: 15px;
}

.event-row p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.message {
  max-width: 78%;
  line-height: 1.35;
}

.message span {
  display: block;
  margin-bottom: 3px;
  text-transform: uppercase;
}

.message p {
  margin: 0;
}

.message.assistant {
  color: var(--text);
}

.message.user {
  justify-self: end;
}

.composer {
  display: grid;
  gap: 8px;
}

.composer input {
  padding: 0 13px;
  outline: none;
}

#recentRuns {
  display: grid;
  gap: 8px;
}

.landing-page {
  overflow: auto;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  align-items: center;
}

.site-brand,
.archive-brand {
  min-width: 0;
}

.site-brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.brand-ai {
  color: var(--coral-red);
  font-style: normal;
}

.site-nav {
  display: flex;
  justify-content: center;
}

.header-cta,
.button-primary,
.button-secondary,
.primary-link {
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.header-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.hero-copy {
  display: grid;
  align-content: center;
}

.hero-copy h1 {
  margin: 0;
  letter-spacing: 0;
}

.hero-copy p {
  margin: 0;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
}

.button-primary,
.button-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.site-footer {
  display: grid;
  gap: 28px;
  align-items: end;
}

.site-footer p {
  margin: 8px 0 0;
}

.site-footer nav {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.site-footer a {
  padding: 8px 10px;
}

.legal-page {
  overflow: auto;
}

.legal-shell {
  max-width: 900px;
  margin: 0 auto;
  padding: 76px 24px;
}

.legal-shell h1 {
  margin: 0 0 22px;
}

.legal-shell > p {
  margin: 0 0 34px;
  color: var(--muted);
  line-height: 1.35;
}

.legal-shell section {
  padding: 24px 0;
}

.legal-shell h2,
.legal-shell p {
  margin: 0;
}

.legal-shell h2 {
  margin-bottom: 10px;
}

/* Admin: gestione crediti e registro delle operazioni */
.admin-notice {
  margin: 14px 0;
  padding: 12px 14px;
  border: 1px solid;
  border-radius: 10px;
  line-height: 1.45;
}

.admin-notice-success {
  color: #145b3d;
  background: #edf8f2;
  border-color: #a8d8c2;
}

.admin-notice-error {
  color: #862319;
  background: #fff2ef;
  border-color: #efb3aa;
}

.admin-table-wrap {
  overflow-x: auto;
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
}

.admin-table {
  width: 100%;
  min-width: 850px;
  border-collapse: collapse;
  font-size: 14px;
}

.admin-table th,
.admin-table td {
  padding: 11px 12px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid #efe9dd;
}

.admin-table th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .02em;
  background: #faf8f3;
}

.admin-table tbody tr:last-child td {
  border-bottom: 0;
}

.admin-muted {
  color: var(--muted);
}

.credit-editor {
  min-width: 145px;
}

.credit-editor summary {
  color: var(--accent-strong);
  font-weight: 700;
  cursor: pointer;
}

.credit-editor form {
  display: grid;
  width: 280px;
  gap: 10px;
  padding: 12px 0 4px;
}

.credit-editor label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.credit-editor input {
  width: 100%;
  padding: 9px 10px;
  color: var(--text);
  font: inherit;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

.credit-editor input:focus {
  outline: 2px solid #9ed7be;
  outline-offset: 1px;
}

.credit-editor small {
  color: var(--muted);
  line-height: 1.4;
}

.credit-editor .button-primary {
  width: 100%;
  padding: 10px 12px;
  border: 0;
  cursor: pointer;
}

.admin-audit-table {
  min-width: 940px;
}

.credit-positive {
  color: #14633f;
}

.credit-negative {
  color: #a22d20;
}

.archive-page {
  overflow: auto;
}

.archive-shell {
  min-height: 100vh;
  padding: 24px;
}

.archive-header {
  display: grid;
  grid-template-columns: 240px 1fr 118px;
  gap: 20px;
  align-items: center;
  max-width: 1320px;
  margin: 0 auto 18px;
}

.archive-header > *,
.archive-toolbar > *,
.archive-grid > *,
.archive-card,
.archive-detail {
  min-width: 0;
}

.archive-brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.archive-brand strong,
.archive-brand em {
  display: block;
}

.archive-brand strong {
  font-size: 16px;
}

.archive-brand em {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.archive-title {
  text-align: center;
}

.archive-title p,
.archive-title h1 {
  margin: 0;
}

.archive-title h1 {
  margin-top: 4px;
  line-height: 1;
}

.primary-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
}

.archive-toolbar {
  display: grid;
  grid-template-columns: 1fr 180px 180px 120px;
  gap: 12px;
  align-items: end;
  max-width: 1320px;
  margin: 0 auto 16px;
  padding: 14px;
}

.archive-toolbar label {
  display: grid;
  gap: 6px;
}

.archive-toolbar span {
  text-transform: uppercase;
}

.archive-toolbar input,
.archive-toolbar select {
  min-height: 38px;
  padding: 0 10px;
  color: var(--text);
  outline: none;
}

.archive-counter {
  display: grid;
  place-items: center;
  min-height: 54px;
}

.archive-counter span {
  color: var(--text);
  font-size: 22px;
}

.archive-counter small {
  color: var(--muted);
  font-size: 11px;
}

.archive-grid {
  display: grid;
  grid-template-columns: minmax(360px, 0.9fr) minmax(460px, 1.1fr);
  gap: 16px;
  max-width: 1320px;
  margin: 0 auto;
  align-items: start;
}

.archive-list,
.archive-detail {
  display: grid;
  gap: 10px;
}

.archive-card {
  width: 100%;
  display: grid;
  gap: 8px;
  padding: 14px;
  text-align: left;
}

.archive-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

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

.archive-card b {
  font-size: 12px;
}

.archive-card strong {
  font-size: 16px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.archive-card small {
  color: var(--muted);
  font-size: 12px;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 11px;
  font-style: normal;
  font-weight: 800;
  white-space: nowrap;
}

.archive-detail {
  position: sticky;
  top: 18px;
  padding: 16px;
}

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

.detail-head p,
.detail-head h2,
.detail-block h3,
.detail-block p {
  margin: 0;
}

.detail-head h2 {
  margin-top: 4px;
  font-size: 28px;
}

.detail-block {
  display: grid;
  gap: 8px;
  padding-top: 14px;
}

.detail-block h3 {
  font-size: 13px;
}

.detail-block p {
  color: var(--muted);
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.detail-block strong {
  font-size: 22px;
}

.detail-block.emphasis p {
  color: var(--text);
  font-size: 18px;
  line-height: 1.4;
}

.detail-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.agent-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.agent-chip-row span {
  padding: 6px 8px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

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

.contribution-list article {
  display: grid;
  gap: 4px;
  padding: 10px;
}

.contribution-list b {
  font-size: 12px;
}

.archive-empty,
.empty-detail {
  padding: 22px;
}

.archive-empty h2,
.archive-empty p,
.empty-detail h2,
.empty-detail p {
  margin: 0;
}

.archive-empty p,
.empty-detail p {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.5;
}

/* ========================================================================
   §3 · RESPONSIVE & OVERRIDE MOBILE  (app-shell + landing mobile)
   ======================================================================== */

@media (max-width: 1180px) {
  body {
    overflow: auto;
  }

}

@media (max-width: 820px) {
.workbench {
    display: grid;
  }

}

/* ========================================================================
   §9 · LAVORAZIONE REALE — overlay agenti e brochure
   ======================================================================== */

.work-overlay {
  position: fixed;
  z-index: 2000;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  overflow-y: auto;
  background: rgba(247, 249, 247, 0.94);
  backdrop-filter: blur(12px);
}

.work-overlay[hidden] {
  display: none;
}

.work-overlay-card {
  width: min(100%, 590px);
  padding: 42px 44px 36px;
  text-align: center;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 30px 90px rgba(17, 35, 28, 0.14);
}

.work-orbit {
  position: relative;
  display: grid;
  place-items: center;
  width: 92px;
  height: 92px;
  margin: 0 auto 24px;
  color: #ffffff;
  font-size: 18px;
  font-weight: 850;
  letter-spacing: -0.03em;
  background: var(--accent-strong);
  border: 10px solid #e3f3eb;
  border-radius: 50%;
}

.work-orbit::before,
.work-orbit::after {
  position: absolute;
  content: "";
  border: 1px solid rgba(23, 107, 86, 0.22);
  border-radius: 50%;
}

.work-orbit::before {
  inset: -17px;
}

.work-orbit::after {
  inset: -25px;
}

.work-orbit i {
  position: absolute;
  z-index: 2;
  width: 10px;
  height: 10px;
  background: var(--coral-red);
  border: 2px solid #ffffff;
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(97, 38, 29, 0.22);
  animation: work-orbit 2.8s linear infinite;
}

.work-orbit i:nth-child(2) {
  animation-delay: -0.93s;
}

.work-orbit i:nth-child(3) {
  animation-delay: -1.86s;
}

.work-label {
  display: block;
  margin-bottom: 10px;
  color: var(--coral-red);
  font-size: 11px;
  font-weight: 820;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.work-overlay-card h2 {
  margin: 0;
  color: var(--text);
  font-size: clamp(25px, 4vw, 34px);
  line-height: 1.1;
  letter-spacing: -0.035em;
}

.work-overlay-card > p {
  max-width: 470px;
  margin: 14px auto 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.55;
}

.work-activity {
  height: 4px;
  margin: 28px 0 18px;
  overflow: hidden;
  background: #e8ebe7;
  border-radius: 99px;
}

.work-activity span {
  display: block;
  width: 38%;
  height: 100%;
  background: linear-gradient(90deg, var(--accent-strong), var(--coral-red));
  border-radius: inherit;
  animation: work-activity 1.8s ease-in-out infinite;
}

.work-overlay-card > small {
  display: block;
  color: #687067;
  font-size: 12px;
  line-height: 1.45;
}

.work-background-link {
  display: inline-flex;
  margin-top: 24px;
}

.work-overlay-card .work-background-note {
  margin-top: 9px;
  font-size: 11px;
}

.work-overlay[data-state="error"] .work-orbit {
  background: var(--danger);
  border-color: #f6dfdc;
}

.work-overlay[data-state="error"] .work-orbit i,
.work-overlay[data-state="error"] .work-activity span {
  animation: none;
}

@keyframes work-orbit {
  from { transform: rotate(0deg) translateX(55px) rotate(0deg); }
  to { transform: rotate(360deg) translateX(55px) rotate(-360deg); }
}

@keyframes work-activity {
  0% { transform: translateX(-105%); }
  50% { transform: translateX(82%); }
  100% { transform: translateX(265%); }
}

@media (max-width: 600px) {
  .work-overlay {
    align-items: center;
    padding: 12px;
  }

  .work-overlay-card {
    padding: 34px 22px 28px;
    border-radius: 16px;
  }

  .work-orbit {
    width: 78px;
    height: 78px;
    margin-bottom: 21px;
    border-width: 8px;
  }

  .work-orbit i {
    animation-name: work-orbit-mobile;
  }
}

@keyframes work-orbit-mobile {
  from { transform: rotate(0deg) translateX(47px) rotate(0deg); }
  to { transform: rotate(360deg) translateX(47px) rotate(-360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .work-orbit i,
  .work-activity span {
    animation-duration: 8s;
  }
}

/* Final mobile app-shell override: later legacy responsive rules should not
   re-expand the old desktop navigation or split the work menu onto a new row. */
@media (max-width: 820px) {
  .site-header,
  .landing-page .site-header {
    position: sticky !important;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto !important;
    align-items: center;
  }
  .site-nav,
  .header-cta {
    display: none !important;
  }
  .work-menu {
    display: block !important;
    grid-column: 2;
    grid-row: 1;
    align-self: center;
  }
.landing-page .hero-command-bar,
  .site-footer {
    display: none !important;
  }
  .mobile-app-bar {
    display: grid !important;
  }
}

/* Final landing-specific pass: keep the home intro quiet, full-screen, and isolated
   from the operational page hero rules above. */
.landing-page .idea-hero {
  min-height: 100svh;
  padding: 86px 40px 126px;
}

.landing-page .idea-hero .hero-copy h1 {
  font-size: clamp(54px, 7vw, 108px);
  font-weight: 280;
  letter-spacing: 0;
}

.landing-page .idea-hero .hero-copy p {
  font-weight: 280 !important;
}

@media (max-width: 820px) {
  .landing-page .idea-hero {
    padding: 34px 16px 0;
  }
  .landing-page .idea-hero .hero-copy {
    transform: none;
  }
  .landing-page .idea-hero .hero-copy h1 {
    font-size: clamp(39px, 12vw, 54px);
    line-height: 1.02;
  }
  .landing-page .idea-hero .hero-copy p {
    max-width: 340px;
    color: #101412;
    font-size: 18px;
    line-height: 1.34;
  }
  .landing-page .idea-hero-bg {
    opacity: 0.28;
    object-position: 32% center;
  }
  .landing-page .hero-command-bar {
    position: relative;
    right: auto;
    bottom: auto;
    left: auto;
    grid-template-columns: 1fr 1fr;
    width: calc(100% + 32px);
    margin: 24px -16px 0;
  }
}

/* ========================================================================
   §4 · NAVIGAZIONE / PWA / SELETTORE MODELLO
   ======================================================================== */
.work-menu,
.mobile-app-bar {
  display: none;
}

.work-menu {
  position: relative;
  justify-self: end;
}

.work-menu summary,
.app-menu summary {
  list-style: none;
}

.work-menu summary::-webkit-details-marker,
.app-menu summary::-webkit-details-marker {
  display: none;
}

.work-menu summary {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 36px;
  padding: 0 12px;
  color: #ffffff;
  background: var(--text);
  border: 1px solid var(--text);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 560;
  cursor: pointer;
}

.menu-glyph {
  position: relative;
  display: inline-block;
  width: 15px;
  height: 10px;
  border-top: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
}

.menu-glyph::after {
  position: absolute;
  top: 3.5px;
  left: 0;
  width: 15px;
  border-top: 1.5px solid currentColor;
  content: "";
}

.work-menu-panel,
.app-menu-panel {
  position: absolute;
  z-index: 80;
  display: grid;
  gap: 4px;
  min-width: 188px;
  padding: 8px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 18px 36px rgba(18, 24, 20, 0.16);
}

.work-menu-panel {
  top: calc(100% + 8px);
  right: 0;
}

.work-menu-panel a,
.app-menu-panel a {
  padding: 10px 11px;
  border-radius: 7px;
  color: var(--text);
  font-size: 13px;
  font-weight: 430;
}

.work-menu-panel a:hover,
.app-menu-panel a:hover,
.work-menu-panel a[aria-current="page"],
.app-menu-panel a[aria-current="page"] {
  background: var(--surface-muted);
}

.workspace-work-menu {
  display: block;
  margin-left: auto;
}

@media (max-width: 820px) {
  body {
    padding-bottom: calc(74px + env(safe-area-inset-bottom));
    overflow-x: hidden;
  }
  .workspace-page,
  .landing-page,
  .flow-page,
  .agents-page,
  .archive-page,
  .legal-page {
    overflow: auto;
  }
  .site-header,
  .landing-page .site-header {
    top: 0;
    z-index: 60;
    min-height: 64px;
    background: #ffffff;
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(12px);
  }
.archive-header {
    gap: 12px;
    align-items: start;
  }
  .archive-brand {
    grid-column: 1 / 2;
  }
  .archive-work-menu {
    display: block;
    grid-column: 2 / 3;
    grid-row: 1 / 2;
  }
  .archive-title,
  .archive-header .primary-link {
    grid-column: 1 / -1;
  }
  .topbar {
    align-items: start;
    gap: 10px;
  }
  .workspace-work-menu {
    display: block;
    order: 2;
  }
  .run-status {
    order: 3;
    width: 100%;
    justify-content: center;
  }
  .landing-page .idea-hero {
    min-height: calc(100svh - 64px);
  }
.mobile-app-bar {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 90;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    min-height: calc(62px + env(safe-area-inset-bottom));
    padding: 7px 8px calc(7px + env(safe-area-inset-bottom));
    background: rgba(255, 255, 255, 0.96);
    border-top: 1px solid var(--border);
    backdrop-filter: blur(16px);
  }
  .mobile-app-bar > a,
  .app-menu summary {
    display: grid;
    place-items: center;
    min-height: 48px;
    padding: 0 6px;
    color: var(--text);
    border-radius: 9px;
    font-size: 12px;
    font-weight: 520;
    cursor: pointer;
  }
  .mobile-app-bar > a[aria-current="page"],
  .app-menu[open] summary {
    color: #ffffff;
    background: var(--text);
  }
  .app-menu {
    position: relative;
  }
  .app-menu summary {
    gap: 5px;
  }
  .app-menu-panel {
    right: 0;
    bottom: calc(100% + 10px);
    min-width: 210px;
  }
  .app-shell {
    padding-bottom: 10px;
  }
  .left-rail {
    padding-right: 16px;
    padding-left: 16px;
  }
}

/* ========================================================================
   §5 · TEMA — direzione visiva 'idea-first'  (2º :root, placeholder, hero)
   ======================================================================== */
:root {
  --font-main: "Avenir Next", "Helvetica Neue", Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/* Placeholder leggibili: senza questa regola il browser usa un grigio troppo chiaro. */
::placeholder {
  color: #646961;
  opacity: 1;
}

body {
  font-family: var(--font-main);
  font-weight: 400;
  text-rendering: geometricPrecision;
}

button,
input,
textarea,
select {
  font-weight: 400;
}

strong,
b,
.site-brand,
.brand h1,
.topbar h2,
.page-hero h1,
.agent-board strong,
.sequence-panel strong,
.hero-command-bar strong {
  font-weight: 420;
}

.landing-page .site-header {
  position: absolute;
  inset: 0 0 auto;
  z-index: 10;
  background: transparent;
  border-bottom: 0;
  backdrop-filter: none;
}

.landing-page .site-nav a,
.landing-page .site-brand {
  color: var(--text);
}

.landing-page main {
  min-height: 100vh;
}

.idea-hero {
  position: relative;
  min-height: 100svh;
  display: grid;
  grid-template-columns: minmax(320px, 0.56fr) minmax(320px, 1fr);
  align-items: center;
  padding: 86px 40px 126px;
  overflow: hidden;
  border-bottom: 0;
  background: #ffffff;
}

.idea-hero-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  pointer-events: none;
}

.idea-hero .hero-copy {
  position: relative;
  z-index: 3;
  max-width: 620px;
  gap: 22px;
  transform: translateY(-34px);
}

.idea-hero .hero-copy h1 {
  max-width: 680px;
  font-size: clamp(54px, 7vw, 108px);
  font-weight: 280;
  line-height: 0.95;
}

.idea-hero .hero-copy p {
  max-width: 520px;
  color: #2d302e;
  font-size: clamp(20px, 2.1vw, 29px);
  font-weight: 280 !important;
  line-height: 1.28;
}

.idea-hero .button-primary,
.idea-hero .button-secondary {
  min-height: 46px;
  padding: 0 18px;
  font-size: 14px;
}

.hero-command-bar {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  background: rgba(255, 255, 255, 0.9);
  border-top: 1px solid var(--border);
  backdrop-filter: blur(14px);
}

.hero-command-bar a {
  display: grid;
  gap: 7px;
  min-height: 104px;
  padding: 20px 40px;
  border-right: 1px solid var(--border);
  transition: background 160ms ease;
}

.hero-command-bar a:last-child {
  border-right: 0;
}

.hero-command-bar a:hover {
  background: #f7fbf8;
}

.hero-command-bar span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 450;
}

.hero-command-bar strong {
  font-size: 23px;
  line-height: 1;
}

.hero-command-bar small {
  color: var(--muted);
  font-size: 13px;
  font-weight: 450;
}

.landing-page .site-footer {
  min-height: 96px;
}

@media (max-width: 1180px) {
  .idea-hero {
    grid-template-columns: 1fr;
    align-items: center;
  }
  .idea-hero-bg {
    object-position: 60% center;
  }
}

@media (max-width: 820px) {
  .landing-page .site-header {
    gap: 10px;
    padding: 12px 16px;
    background: #ffffff;
    border-bottom: 1px solid var(--border);
  }
  .landing-page .site-nav {
    grid-column: auto;
  }
  .idea-hero {
    min-height: calc(100svh - 149px);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 34px 16px 0;
    align-items: start;
  }
  .idea-hero-bg {
    opacity: 0.5;
    object-position: 60% center;
  }
  .idea-hero .hero-copy {
    max-width: 360px;
    gap: 18px;
    transform: none;
  }
  .idea-hero .hero-copy h1 {
    font-size: clamp(39px, 12vw, 54px);
    line-height: 1.02;
  }
  .idea-hero .hero-copy p {
    max-width: 340px;
    font-size: 18px;
    line-height: 1.34;
  }
  .idea-hero .hero-actions,
  .idea-hero .button-primary,
  .idea-hero .button-secondary {
    width: 100%;
  }
  .hero-command-bar {
    position: relative;
    right: auto;
    bottom: auto;
    left: auto;
    grid-template-columns: 1fr 1fr;
    width: calc(100% + 32px);
    margin: 24px -16px 0;
  }
  .hero-command-bar a {
    min-height: 84px;
    padding: 16px;
  }
  .hero-command-bar a:nth-child(2) {
    border-right: 0;
  }
  .hero-command-bar a:nth-child(-n+2) {
    border-bottom: 1px solid var(--border);
  }
  .hero-command-bar strong {
    font-size: 20px;
  }
}

/* ========================================================================
   §6 · PAGINE — Processo & Agenti
   ======================================================================== */
.site-nav a[aria-current="page"] {
  color: var(--text);
  background: var(--surface-muted);
}

.sequence-panel span,
.agent-board span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.flow-page,
.agents-page {
  overflow: auto;
  background: #ffffff;
}

.page-shell {
  min-height: calc(100vh - 164px);
  padding: 40px;
}

.process-shell,
.agents-shell {
  display: grid;
  align-content: start;
  gap: 28px;
}

.page-hero {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 24px;
  align-items: end;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.page-hero h1,
.page-hero p {
  margin: 0;
}

.page-hero h1 {
  font-size: clamp(42px, 6vw, 76px);
  line-height: 1;
}

.page-hero p {
  margin-top: 10px;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.45;
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: end;
  gap: 10px;
}

.sequence-panel {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.sequence-panel a {
  display: grid;
  align-content: space-between;
  min-height: 268px;
  padding: 20px;
  background: #ffffff;
}

.sequence-panel a:nth-child(even) {
  background: #fbfbfa;
}

.sequence-panel a:hover {
  background: var(--accent);
}

.sequence-panel strong {
  display: block;
  margin-top: auto;
  font-size: 24px;
  line-height: 1;
}

.sequence-panel small {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.agent-board {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.agent-board article {
  display: grid;
  gap: 8px;
  min-height: 164px;
  padding: 16px;
  background: #ffffff;
}

.agent-board article:nth-child(4n+2),
.agent-board article:nth-child(4n+3) {
  background: #fbfbfa;
}

.agent-board article:nth-child(4n) {
  background: #f7fbf8;
}

.agent-board strong {
  font-size: 20px;
  line-height: 1.05;
}

.agent-board small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.agent-board p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.compact-footer {
  min-height: 92px;
}

@media (max-width: 1180px) {

  .sequence-panel {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .sequence-panel a {
    min-height: 190px;
  }
  .agent-board {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 820px) {

  .sequence-panel,
.agent-board,
.page-hero {
    grid-template-columns: 1fr;
  }

  .page-shell {
    min-height: 0;
    padding: 32px 16px;
  }
  .page-hero {
    align-items: start;
  }
  .page-actions {
    justify-content: stretch;
  }
  .page-actions .button-primary,
  .page-actions .button-secondary {
    width: 100%;
  }
  .sequence-panel a {
    min-height: 120px;
  }
  .agent-board article {
    min-height: 132px;
  }
}

/* ========================================================================
   §7 · TEMA — workspace & rifiniture  (grande layer di override)
   ======================================================================== */
body {
  background: #ffffff;
  color: var(--text);
}

button,
input,
textarea,
select {
  color: var(--text);
}

.workbench {
  gap: 12px;
  padding: 18px;
}

.section-heading,
.workspace-label,
.focus-kicker,
.archive-title p,
.archive-toolbar span,
.detail-head p,
.message span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0;
}

/* Sottotitoli descrittivi (frasi, non micro-label): fuori dal gruppo sopra. */
.archive-title p,
.detail-head p {
  font-size: 14px;
  font-weight: 400;
  line-height: 1.45;
  letter-spacing: 0;
  text-transform: none;
}

textarea,
.composer input,
.archive-toolbar input,
.archive-toolbar select {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 8px;
}

textarea {
  min-height: 100px;
  padding: 11px;
  line-height: 1.45;
}

textarea:focus,
input:focus,
.archive-toolbar input:focus,
.archive-toolbar select:focus {
  border-color: #9bbbab;
  box-shadow: 0 0 0 3px rgba(23, 107, 86, 0.1);
}

.range-row {
  grid-template-columns: 78px 1fr 34px;
  font-size: 11px;
}

.range-row input {
  accent-color: var(--accent-strong);
}

.launch-button,
.composer button,
.header-cta,
.button-primary,
.primary-link {
  color: #ffffff;
  background: var(--text);
  border: 1px solid var(--text);
  border-radius: 8px;
  box-shadow: none;
  font-weight: 680;
}

.launch-button {
  min-height: 40px;
}

.button-secondary {
  color: var(--text);
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: none;
  font-weight: 680;
}

.header-cta,
.primary-link {
  min-height: 36px;
}

.header-cta:hover,
.button-primary:hover,
.button-secondary:hover,
.primary-link:hover,
.launch-button:hover,
.composer button:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(18, 24, 20, 0.08);
}

.topbar h2 {
  font-size: 23px;
  line-height: 1.1;
}

.run-status {
  padding: 7px 10px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: none;
  font-size: 12px;
}

.status-dot.completed {
  background: var(--accent-strong);
}

.status-dot.running {
  background: #c99522;
}

.event-row {
  grid-template-columns: 86px 1fr;
  gap: 12px;
  padding: 12px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 9px;
}

.message {
  padding: 9px 11px;
  border-radius: 9px;
}

.message.assistant {
  background: #f6f6f4;
  border: 1px solid var(--border);
}

.message.user {
  color: var(--text);
  background: #eef4f0;
  border: 1px solid #c9ddd4;
}

.composer {
  grid-template-columns: 1fr 76px;
}

.composer input {
  min-height: 40px;
}

.archive-empty,
.empty-detail,
.contribution-list article {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 9px;
}

.site-header {
  min-height: 64px;
  grid-template-columns: 210px 1fr 132px;
  gap: 20px;
  padding: 12px 28px;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
}

.site-brand {
  font-size: 16px;
  font-weight: 720;
}

.site-nav {
  gap: 4px;
}

.site-nav a {
  padding: 7px 9px;
  color: var(--muted);
  border: 1px solid transparent;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 620;
}

.site-nav a:hover {
  color: var(--text);
  background: var(--surface-muted);
  border-color: transparent;
}

.landing-page,
.legal-page,
.archive-page {
  background: #ffffff;
}

.hero-copy {
  gap: 18px;
  max-width: 660px;
}

.hero-copy h1 {
  font-size: clamp(38px, 4.8vw, 64px);
  line-height: 1.04;
  font-weight: 760;
}

.hero-copy p {
  max-width: 560px;
  color: var(--muted);
  font-size: clamp(16px, 1.4vw, 19px);
  line-height: 1.45;
}

.hero-actions {
  gap: 10px;
}

.button-primary,
.button-secondary {
  min-height: 44px;
  padding: 0 16px;
  border-width: 1px;
  font-size: 14px;
}

.button-secondary {
  color: var(--text);
  background: #ffffff;
}

.site-footer {
  grid-template-columns: 1fr auto;
  padding: 30px 32px;
  color: var(--text);
  background: #ffffff;
  border-top: 1px solid var(--border);
}

.site-footer strong {
  font-size: 18px;
  font-weight: 720;
}

.site-footer p {
  color: var(--muted);
}

.site-footer a {
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-weight: 620;
}

.legal-shell h1 {
  font-size: clamp(38px, 6vw, 72px);
  line-height: 1.04;
}

.legal-shell > p {
  font-size: 18px;
}

.legal-shell section {
  border-top: 1px solid var(--border);
}

.archive-shell {
  background: #ffffff;
}

.archive-title h1 {
  font-size: 30px;
}

.archive-toolbar,
.archive-card,
.archive-detail {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: none;
}

.archive-counter {
  background: var(--accent);
  border: 1px solid #b8d6c9;
  border-radius: 8px;
}

.archive-card.selected {
  background: var(--accent);
  border-color: #b8d6c9;
  box-shadow: none;
}

.status-chip.completed,
.status-chip.running,
.status-chip.pending,
.status-chip.failed,
.agent-chip-row span {
  border: 1px solid var(--border);
}

.status-chip.completed,
.agent-chip-row span {
  color: var(--accent-strong);
  background: var(--accent);
  border-color: #b8d6c9;
}

.status-chip.running,
.status-chip.pending {
  color: #7a5b16;
  background: var(--warning);
  border-color: #e4d29d;
}

.status-chip.failed {
  color: #8a3a33;
  background: var(--coral);
  border-color: #e5bdb7;
}

.detail-block {
  border-top: 1px solid var(--border);
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 280px minmax(0, 1fr);
    height: auto;
    min-height: 100vh;
  }

  .archive-grid {
    grid-template-columns: 1fr;
  }
  .archive-detail {
    position: static;
  }
}

@media (max-width: 820px) {
  .app-shell {
    display: block;
  }
  .left-rail,
.workbench {
    min-height: auto;
  }
  .left-rail {
    overflow: visible;
  }
  .agents-section {
    flex: none;
    min-height: 0;
    grid-template-rows: auto auto;
  }
  .agents-section .agent-list {
    max-height: none;
    overflow: visible;
  }
  .workbench {
    padding: 16px;
  }
  .event-row,
.archive-header,
.archive-toolbar,
.detail-split {
    grid-template-columns: 1fr;
  }
  .site-header {
    gap: 12px;
    padding: 12px 16px;
  }
  .site-nav {
    grid-column: 1 / -1;
    justify-content: start;
    flex-wrap: nowrap;
    overflow-x: auto;
  }
  .header-cta {
    width: auto;
    min-height: 36px;
    padding: 0 12px;
  }

  .hero-copy h1 {
    font-size: clamp(39px, 12vw, 54px);
  }
  .hero-copy p {
    font-size: 16px;
  }
  .hero-actions,
  .button-primary,
  .button-secondary {
    width: 100%;
  }

  .site-footer {
    grid-template-columns: 1fr;
  }

  .archive-shell {
    padding: 16px;
  }
  .archive-title {
    text-align: left;
  }
  .site-footer {
    align-items: start;
    padding: 26px 16px;
  }
  .site-footer nav {
    flex-direction: column;
  }
}

/* ========================================================================
   §8 · PAGINE SPECIFICHE — motori AI, modalità, config/run, vista run, dossier
   ======================================================================== */
.engine-choice {
  display: flex;
  align-items: center;
  gap: .6rem;
  flex-wrap: wrap;
  margin: 1rem 0 1.4rem;
}
.engine-chip {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .45rem .85rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, .85);
  border: 1px solid rgba(0, 0, 0, .08);
  font-weight: 700;
  font-size: .95rem;
}
.engine-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}
.engine-dot.openai { background: #10a37f; }
.engine-dot.claude { background: #d97757; }
.engine-or { color: var(--muted); font-size: .85rem; }

/* --- Selettore modalità Standard / Advanced nel Tavolo --- */
.mode-switch {
  display: flex;
  gap: .35rem;
  background: rgba(0, 0, 0, .05);
  padding: .25rem;
  border-radius: 12px;
  margin: 0 0 1rem;
}
.mode-switch button {
  flex: 1;
  border: none;
  padding: .5rem .6rem;
  border-radius: 9px;
  font-weight: 700;
  font-size: .9rem;
  cursor: pointer;
  color: #fff;
  opacity: .76;
  transition: opacity .18s ease, box-shadow .18s ease, transform .18s ease;
}
.mode-switch button[data-mode="standard"] {
  background: #0b7a53;
}
.mode-switch button[data-mode="advanced"] {
  background: #2457c5;
}
.mode-switch button:hover {
  opacity: .92;
}
.mode-switch button:focus-visible {
  outline: 2px solid #111;
  outline-offset: 2px;
}
.mode-switch button.active {
  opacity: 1;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .72), 0 1px 4px rgba(0, 0, 0, .18);
}
body.mode-standard .advanced-only { display: none; }

/* --- Pagina di configurazione + vista run (mobile-first) --- */
.form-page { background: #f6f3ec; min-height: 100vh; }
.form-shell {
  max-width: 680px;
  margin: 0 auto;
  padding: 1.4rem 1.1rem 6rem;
}
.form-shell h1 { margin: .2rem 0 .3rem; font-size: 1.7rem; }

.validation-mode-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .75rem;
  margin: .35rem 0 1rem;
}
.validation-mode-card {
  position: relative;
  min-height: 145px;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  color: var(--text);
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  cursor: pointer;
}
.validation-mode-card:hover,
.validation-mode-card.active { border-color: var(--coral); box-shadow: 0 0 0 2px rgba(239, 92, 71, .12); }
.validation-mode-card > span:not(.mode-badge) { color: var(--muted); font-size: .88rem; line-height: 1.35; }
.validation-mode-card > b { margin-top: auto; font-size: .92rem; }
.mode-badge { align-self: flex-start; padding: .18rem .45rem; border-radius: 999px; background: #fff0ed; color: #ad3425; font-size: .7rem; font-weight: 800; text-transform: uppercase; }
.cost-explainer { margin-top: -.3rem; }
.clarify-box[hidden] { display: none !important; }

@media (max-width: 700px) {
  .validation-mode-list { grid-template-columns: 1fr; }
  .validation-mode-card { min-height: 0; }
}

/* ========================================================================
   §13 · TAVOLO FOCALIZZATO — dossier ampio, un solo prossimo passo
   ======================================================================== */

.workspace-layout.run-workspace-focused {
  grid-template-columns: 280px minmax(0, 1fr);
}

.run-workspace-focused .run-canvas {
  min-height: calc(100vh - 64px);
}

.run-workspace-focused .run-title {
  display: grid;
  grid-template-columns: minmax(230px, .62fr) minmax(520px, 1.38fr);
  gap: 28px;
  align-items: end;
}

.run-workspace-focused .run-title .dossier-export {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 7px;
}

.run-workspace-focused .dossier-export .button-primary,
.run-workspace-focused .dossier-export .button-secondary {
  min-height: 40px;
  padding: 0 12px;
  font-size: 12px;
  line-height: 1.15;
  text-align: center;
}

.run-brochure-action {
  color: var(--accent-strong);
  background: var(--accent);
  border-color: #b8d6c9;
}

.run-brochure-action.is-progress {
  color: #73540f;
  background: #fff8e7;
  border-color: #e4d29d;
}

.run-action-divider {
  align-self: stretch;
  width: 1px;
  min-height: 34px;
  margin: 2px 3px;
  background: var(--border);
}

.run-quote-action {
  color: #9b3428;
  background: #fff0ed;
  border-color: #efb3aa;
}

.run-quote-action:hover {
  color: #76261d;
  background: #ffe3dd;
  border-color: #e99083;
}

.rail-next-step {
  display: grid;
  gap: 9px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.rail-next-step[hidden] {
  display: none;
}

.rail-next-step > span {
  color: var(--accent-strong);
  font-size: 10px;
  font-weight: 820;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.rail-next-step h2,
.rail-next-step p {
  margin: 0;
}

.rail-next-step h2 {
  font-size: 17px;
  line-height: 1.2;
}

.rail-next-prompt {
  display: -webkit-box;
  overflow: hidden;
  color: #535b55;
  font-size: 12px;
  line-height: 1.5;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 7;
}

.rail-next-prompt.is-expanded {
  display: block;
  overflow: visible;
}

.rail-prompt-toggle {
  justify-self: start;
  padding: 0;
  color: var(--accent-strong);
  background: transparent;
  border: 0;
  font: inherit;
  font-size: 11px;
  font-weight: 760;
  cursor: pointer;
}

.rail-next-step .button-primary {
  width: 100%;
  min-height: 42px;
  padding: 0 10px;
  text-align: center;
}

.rail-next-step > small {
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

.rail-next-step > small strong {
  color: var(--coral-red);
}

.rail-next-step > em {
  color: var(--muted);
  font-size: 10px;
  font-style: normal;
  line-height: 1.4;
  text-align: center;
}

@media (max-width: 1240px) {
  .workspace-layout.run-workspace-focused {
    grid-template-columns: 240px minmax(0, 1fr);
  }

  .run-workspace-focused .run-title {
    grid-template-columns: 1fr;
  }

  .run-workspace-focused .run-title .dossier-export {
    justify-content: flex-start;
  }
}

@media (max-width: 820px) {
  .workspace-layout.run-workspace-focused {
    display: block;
  }

  .run-workspace-focused .run-rail {
    padding-bottom: 20px;
  }

  .run-workspace-focused .run-status {
    order: 0;
  }

  .run-workspace-focused .run-nav {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .run-workspace-focused .run-nav a {
    text-align: center;
  }

  .run-workspace-focused .rail-next-step {
    max-width: none;
  }

  .run-workspace-focused .run-title .dossier-export {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .run-workspace-focused .run-action-divider {
    display: none;
  }

  .run-workspace-focused .run-quote-action {
    grid-column: 1 / -1;
  }
}

@media (max-width: 520px) {
  .run-workspace-focused .run-title .dossier-export {
    grid-template-columns: 1fr;
  }

  .run-workspace-focused .run-quote-action {
    grid-column: auto;
  }
}

/* ==========================================================================
   §15 · DRAWER IMPOSTAZIONI AVANZATE
   ========================================================================== */

.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;
}

body.drawer-open {
  overflow: hidden;
}

.advanced-summary {
  display: grid;
  gap: 10px;
  padding: 12px;
  background: #e8f5ef;
  border: 1px solid #b8d9cb;
  border-radius: 10px;
}

.advanced-summary[hidden],
.advanced-drawer-layer[hidden] {
  display: none;
}

.advanced-summary > div {
  display: grid;
  gap: 3px;
}

.advanced-summary strong {
  color: var(--accent-strong);
  font-size: 12px;
}

.advanced-summary span {
  color: var(--muted);
  font-size: 11px;
}

.advanced-summary button {
  min-height: 34px;
  color: var(--text);
  background: #ffffff;
  border: 1px solid #b8d9cb;
  border-radius: 8px;
  font: inherit;
  font-size: 11px;
  font-weight: 780;
  cursor: pointer;
}

.advanced-drawer-layer {
  position: fixed;
  z-index: 1800;
  inset: 0;
  display: grid;
  justify-items: end;
}

.advanced-drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(18, 20, 18, 0.28);
  backdrop-filter: blur(2px);
}

.advanced-drawer {
  position: relative;
  width: min(590px, calc(100vw - 32px));
  height: 100dvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  color: var(--text);
  background: #ffffff;
  border-left: 1px solid var(--border);
  box-shadow: -24px 0 70px rgba(17, 20, 18, 0.18);
  animation: advanced-drawer-in 190ms ease-out both;
}

@keyframes advanced-drawer-in {
  from { transform: translateX(36px); opacity: 0.7; }
  to { transform: translateX(0); opacity: 1; }
}

.advanced-drawer-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 20px;
  padding: 22px 24px 18px;
  border-bottom: 1px solid var(--border);
}

.advanced-drawer-header > div {
  display: grid;
  gap: 5px;
}

.advanced-drawer-header span {
  color: var(--accent-strong);
  font-size: 11px;
  font-weight: 820;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.advanced-drawer-header h2,
.advanced-drawer-header p {
  margin: 0;
}

.advanced-drawer-header h2 {
  font-size: clamp(24px, 3vw, 32px);
  line-height: 1.05;
}

.advanced-drawer-header h2:focus {
  outline: 0;
}

.advanced-drawer-header p {
  max-width: 460px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.advanced-drawer-close {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  color: var(--text);
  background: #f5f5f2;
  border: 1px solid var(--border);
  border-radius: 50%;
  font: inherit;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.advanced-drawer-body {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 20px 24px 32px;
  scrollbar-gutter: stable;
}

.drawer-section {
  display: grid;
  gap: 13px;
  padding: 18px 0;
  border-bottom: 1px solid var(--border);
}

.drawer-section:first-child {
  padding-top: 0;
}

.drawer-section:last-child {
  border-bottom: 0;
}

.drawer-section-heading {
  display: grid;
  gap: 3px;
}

.drawer-section-heading strong {
  font-size: 15px;
}

.drawer-section-heading span {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

.advanced-drawer .field-select {
  min-height: 46px;
  padding: 0 13px;
  border-radius: 9px;
}

.advanced-drawer .form-hint {
  margin: -4px 0 0;
  font-size: 11px;
  line-height: 1.4;
}

.advanced-drawer .agent-list {
  gap: 0;
  border-top: 1px solid var(--border);
}

.advanced-drawer .agent-row {
  grid-template-columns: minmax(0, 1fr) 124px;
  gap: 16px;
  min-height: 58px;
  padding: 9px 0;
}

.advanced-drawer .agent-meta {
  display: grid;
  gap: 3px;
}

.advanced-drawer .agent-meta strong {
  font-size: 12px;
}

.advanced-drawer .agent-meta span {
  display: block;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.35;
}

.advanced-drawer .state-toggle button {
  height: 28px;
  cursor: pointer;
}

.advanced-drawer .state-toggle:not(.locked) {
  grid-template-columns: repeat(2, 1fr);
}

.advanced-drawer .state-toggle.locked {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  color: var(--accent-strong);
  background: #e8f5ef;
  border-color: #b8d9cb;
  opacity: 1;
}

.mandatory-state {
  font-size: 10px;
  font-weight: 800;
}

.advanced-drawer .state-toggle button:disabled {
  cursor: not-allowed;
}

.advanced-drawer .param-grid {
  gap: 0;
  padding: 2px 14px;
  background: #fafaf8;
  border: 1px solid var(--border);
  border-radius: 9px;
}

.advanced-drawer .range-row {
  grid-template-columns: 112px minmax(0, 1fr) 34px;
  min-height: 48px;
  border-bottom: 1px solid var(--border);
  font-size: 11px;
}

.advanced-drawer .range-row:last-child {
  border-bottom: 0;
}

.advanced-drawer-footer {
  display: grid;
  grid-template-columns: minmax(150px, 0.75fr) minmax(300px, 1.25fr);
  gap: 14px;
  align-items: center;
  padding: 16px 24px max(16px, env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.97);
  border-top: 1px solid var(--border);
  box-shadow: 0 -12px 28px rgba(20, 24, 21, 0.06);
}

.drawer-live-cost {
  display: grid;
  gap: 3px;
}

.drawer-live-cost > span {
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
}

.drawer-live-cost strong {
  font-size: 13px;
}

.drawer-live-cost b {
  font: inherit;
}

.drawer-footer-actions {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.2fr);
  gap: 8px;
}

.drawer-reset-button,
.drawer-apply-button {
  min-height: 44px;
  padding: 0 12px;
  border-radius: 8px;
  font: inherit;
  font-size: 11px;
  font-weight: 780;
  cursor: pointer;
}

.drawer-reset-button {
  color: var(--text);
  background: #ffffff;
  border: 1px solid var(--border);
}

.advanced-drawer button:focus-visible,
.advanced-drawer select:focus-visible,
.advanced-drawer input:focus-visible,
.advanced-summary button:focus-visible {
  outline: 3px solid rgba(39, 126, 94, 0.22);
  outline-offset: 2px;
}

@media (max-width: 700px) {
  .advanced-drawer {
    width: 100%;
    border-left: 0;
  }

  .advanced-drawer-header {
    padding: 17px 16px 14px;
  }

  .advanced-drawer-header h2 {
    font-size: 25px;
  }

  .advanced-drawer-body {
    padding: 16px 16px 28px;
  }

  .advanced-drawer-footer {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 12px 16px max(12px, env(safe-area-inset-bottom));
  }

  .drawer-live-cost {
    grid-template-columns: 1fr auto;
    align-items: center;
  }
}

@media (max-width: 460px) {
  .advanced-drawer .agent-row {
    grid-template-columns: minmax(0, 1fr) 124px;
    gap: 10px;
  }

  .advanced-drawer .agent-meta span {
    display: none;
  }

  .advanced-drawer .range-row {
    grid-template-columns: 94px minmax(0, 1fr) 28px;
  }

  .drawer-footer-actions {
    grid-template-columns: 1fr 1.15fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .advanced-drawer {
    animation: none;
  }
}

/* ========================================================================
   §12 · TRE OUTPUT — relazione, dossier tecnico, brochure
   ======================================================================== */

.archive-page .archive-grid {
  display: block;
  max-width: 1320px;
}

.archive-page .archive-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.archive-page .archive-card {
  min-height: 200px;
}

.archive-card-main {
  text-decoration: none;
}

.archive-card-main:hover > strong {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.archive-card-actions {
  width: 174px;
}

.output-breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.output-breadcrumb a {
  color: var(--text);
}

.output-kicker {
  display: inline-flex;
  color: var(--accent-strong);
  font-size: 11px;
  font-weight: 820;
  letter-spacing: .07em;
  text-transform: uppercase;
}

.output-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.output-actions .button-primary,
.output-actions .button-secondary,
.brochure-ready-actions .button-primary,
.brochure-ready-actions .button-secondary {
  min-height: 42px;
  padding-inline: 14px;
  white-space: nowrap;
}

.output-brochure-link {
  color: var(--accent-strong);
  background: var(--accent);
  border-color: #b8d6c9;
}

/* Relazione: documento editoriale, senza il rumore tecnico degli agenti. */
.relation-shell {
  width: min(1120px, calc(100% - 48px));
  margin: 0 auto;
  padding: 28px 0 96px;
}

.relation-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 36px;
  align-items: end;
  padding: 42px 0 30px;
  border-bottom: 1px solid var(--border);
}

.relation-hero-copy h1,
.relation-hero-copy p,
.relation-lead h2,
.relation-lead p {
  margin: 0;
}

.relation-hero-copy h1 {
  max-width: 820px;
  margin-top: 10px;
  font-size: clamp(34px, 5vw, 62px);
  line-height: .98;
  letter-spacing: -.045em;
}

.relation-hero-copy > p {
  margin-top: 16px;
  color: var(--muted);
  font-size: 17px;
}

.relation-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-top: 20px;
  color: var(--muted);
  font-size: 12px;
}

.relation-meta strong {
  color: var(--accent-strong);
}

.relation-notice {
  margin-top: 20px;
  padding: 16px 18px;
  color: #73540f;
  background: #fff8e7;
  border: 1px solid #e4d29d;
  border-radius: 10px;
}

.relation-notice p {
  margin: 4px 0 0;
}

.relation-document {
  width: min(860px, 100%);
  margin: 0 auto;
}

.relation-lead {
  padding: 70px 0 54px;
}

.relation-lead > span,
.relation-decision-grid span,
.relation-next > span {
  color: var(--accent-strong);
  font-size: 11px;
  font-weight: 820;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.relation-lead h2 {
  margin-top: 13px;
  font-size: clamp(25px, 3.8vw, 40px);
  line-height: 1.16;
  letter-spacing: -.025em;
}

.relation-lead p {
  margin-top: 18px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.7;
}

.relation-decision-grid {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  border-block: 1px solid var(--border);
}

.relation-decision-grid > div {
  padding: 28px 26px 30px 0;
}

.relation-decision-grid > div + div {
  padding-left: 26px;
  border-left: 1px solid var(--border);
}

.relation-decision-grid p {
  margin: 10px 0 0;
  color: #4c534e;
  font-size: 16px;
  line-height: 1.6;
}

.relation-decision-grid .relation-decision-primary p {
  color: var(--text);
  font-size: 20px;
  line-height: 1.45;
}

.relation-section {
  padding: 52px 0;
  border-bottom: 1px solid var(--border);
}

.relation-section > header {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 14px;
  align-items: baseline;
}

.relation-section > header span {
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 820;
}

.relation-section > header h2 {
  margin: 0;
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1.1;
  letter-spacing: -.025em;
}

.relation-prose {
  margin: 24px 0 0 56px;
  color: #3f4641;
  font-size: 17px;
  line-height: 1.72;
  white-space: pre-line;
}

.relation-finding-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 28px 42px;
  margin: 32px 0 0 56px;
}

.relation-finding-grid h3 {
  margin: 0 0 10px;
  color: var(--accent-strong);
  font-size: 12px;
  text-transform: uppercase;
}

.relation-finding-grid ul,
.relation-why ol {
  margin: 0;
  padding-left: 18px;
}

.relation-finding-grid li,
.relation-why li {
  margin: 0 0 8px;
  color: #555d57;
  line-height: 1.52;
}

.relation-why ol {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 42px;
  margin: 28px 0 0 56px;
}

.relation-plan ol {
  display: grid;
  gap: 0;
  margin: 28px 0 0 56px;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--border);
}

.relation-plan li {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 12px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}

.relation-plan li > span {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  color: var(--accent-strong);
  background: var(--accent);
  border-radius: 50%;
  font-size: 11px;
  font-weight: 820;
}

.relation-plan li p {
  margin: 3px 0 0;
  line-height: 1.55;
}

.relation-next {
  margin-top: 52px;
  padding: 28px;
  background: var(--accent);
  border: 1px solid #b8d6c9;
  border-radius: 12px;
}

.relation-next p {
  margin: 10px 0 20px;
  font-size: 18px;
  line-height: 1.5;
}

/* Brochure: un'unica destinazione per creare, aprire e recuperare versioni. */
.brochure-shell {
  width: min(1180px, calc(100% - 48px));
  margin: 0 auto;
  padding: 28px 0 96px;
}

.brochure-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 30px;
  align-items: end;
  padding: 42px 0 30px;
  border-bottom: 1px solid var(--border);
}

.brochure-hero h1,
.brochure-hero p,
.brochure-main-panel h2,
.brochure-main-panel p,
.brochure-create-panel h2 {
  margin: 0;
}

.brochure-hero h1 {
  max-width: 800px;
  margin-top: 10px;
  font-size: clamp(32px, 4.5vw, 54px);
  line-height: 1;
  letter-spacing: -.04em;
}

.brochure-hero p {
  margin-top: 13px;
  color: var(--muted);
}

.brochure-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(300px, .6fr);
  gap: 16px;
  margin-top: 24px;
}

.brochure-main-panel,
.brochure-create-panel,
.brochure-history {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
}

.brochure-main-panel {
  min-height: 430px;
  padding: clamp(28px, 5vw, 58px);
  background: linear-gradient(145deg, #fbfcfa 0%, #eef8f3 100%);
}

.brochure-main-panel h2 {
  max-width: 620px;
  margin-top: 12px;
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1.06;
  letter-spacing: -.035em;
}

.brochure-main-panel p {
  max-width: 580px;
  margin-top: 18px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.6;
}

.brochure-ready-mark {
  display: grid;
  place-items: center;
  width: 90px;
  height: 116px;
  margin-bottom: 28px;
  color: #fff;
  background: var(--text);
  border-radius: 6px 18px 6px 6px;
  box-shadow: 0 16px 32px rgba(22, 34, 27, .14);
}

.brochure-ready-mark span {
  font-size: 15px;
  font-weight: 850;
  letter-spacing: .06em;
}

.brochure-ready-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 28px;
}

.brochure-create-panel {
  align-self: start;
  padding: 24px;
}

.brochure-create-panel h2 {
  margin-top: 8px;
  font-size: 23px;
}

.brochure-create-panel .brochure-controls {
  margin-top: 20px;
}

.brochure-create-panel .button-primary {
  width: 100%;
  min-height: 46px;
  margin-top: 18px;
  border: 0;
}

.brochure-history {
  margin-top: 16px;
  padding: 22px;
}

.brochure-history header h2 {
  margin: 7px 0 18px;
  font-size: 24px;
}

.brochure-history > div {
  display: grid;
  gap: 8px;
}

.brochure-history article {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  background: #fbfbfa;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.brochure-history article > div {
  display: grid;
  gap: 2px;
}

.brochure-history small {
  color: var(--muted);
}

.brochure-history article > a {
  font-size: 12px;
  font-weight: 780;
}

.preview-intro {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.run-output-links {
  display: grid;
  gap: 8px;
}

.run-output-links a {
  display: grid;
  gap: 3px;
  padding: 12px;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.run-output-links a:hover {
  border-color: #93bbaa;
}

.run-output-links span {
  color: var(--muted);
  font-size: 11px;
}

@media (max-width: 1050px) {
  .archive-page .archive-list {
    grid-template-columns: 1fr;
  }

  .archive-page .archive-card {
    min-height: 0;
  }
}

@media (max-width: 820px) {
  .relation-shell,
  .brochure-shell {
    width: calc(100% - 32px);
    padding-bottom: 96px;
  }

  .relation-hero,
  .brochure-hero,
  .brochure-layout {
    grid-template-columns: 1fr;
  }

  .relation-hero,
  .brochure-hero {
    padding-top: 28px;
  }

  .output-actions {
    justify-content: flex-start;
  }

  .relation-lead {
    padding: 44px 0 38px;
  }

  .relation-decision-grid,
  .relation-finding-grid,
  .relation-why ol {
    grid-template-columns: 1fr;
  }

  .relation-decision-grid > div,
  .relation-decision-grid > div + div {
    padding: 22px 0;
    border-left: 0;
  }

  .relation-decision-grid > div + div {
    border-top: 1px solid var(--border);
  }

  .relation-section {
    padding: 40px 0;
  }

  .relation-prose,
  .relation-finding-grid,
  .relation-why ol,
  .relation-plan ol {
    margin-left: 0;
  }

  .brochure-main-panel {
    min-height: 0;
  }
}

@media (max-width: 700px) {
  .archive-page .archive-card-actions {
    width: auto;
    grid-template-columns: 1fr;
  }

  .archive-page .archive-card-actions .archive-action-primary {
    grid-column: auto;
  }

  .output-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .output-actions > * {
    width: 100%;
  }

  .relation-section > header {
    grid-template-columns: 30px minmax(0, 1fr);
    gap: 8px;
  }

  .brochure-history article {
    grid-template-columns: 1fr auto;
  }
}
.form-sub { color: var(--muted); margin: 0 0 1.2rem; line-height: 1.5; }
.field-label {
  display: block;
  font-weight: 700;
  font-size: .85rem;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: var(--muted);
  margin: 1.3rem 0 .5rem;
}
#commandInput, .field-select {
  width: 100%;
  padding: .85rem 1rem;
  border: 1px solid #d6cfc0;
  border-radius: 14px;
  background: #fff;
  font-size: 1rem;
  font-family: inherit;
  box-sizing: border-box;
}
#commandInput { resize: vertical; }
.form-hint { font-size: .9rem; color: var(--muted); margin: .4rem 0 0; }
.param-grid { display: grid; gap: .6rem; }
.cost-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin: 1.6rem 0 1rem;
  padding: .85rem 1.1rem;
  background: #fff;
  border: 1px solid #e3ddd1;
  border-radius: 14px;
  font-size: .95rem;
}
.form-page .launch-button { width: 100%; margin-top: .4rem; }
.form-error { color: #b3261e; font-weight: 600; margin-top: .8rem; }

/* Vista run */
.run-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.result-panel {
  background: #fff;
  border: 1px solid #e3ddd1;
  border-radius: 18px;
  padding: 1.3rem;
  margin: 1rem 0 1.6rem;
}
.result-panel h2 { margin: .3rem 0 .6rem; font-size: 1.35rem; }
.result-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin-top: 1rem;
}
.result-grid h3, .next-prompt h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); margin: 0 0 .4rem; }
.next-prompt { margin-top: 1.2rem; padding-top: 1.2rem; border-top: 1px solid #efe9dd; }
.next-prompt .button-secondary { margin-top: .8rem; display: inline-block; }

.topbar-account {
  text-decoration: none;
  font-weight: 700;
  font-size: .9rem;
  padding: .4rem .85rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  white-space: nowrap;
  background: var(--surface);
}
.topbar-account:hover { background: var(--accent); }

.pitch-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.verdict-badge {
  font-weight: 800;
  font-size: .9rem;
  padding: .3rem .8rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  white-space: nowrap;
}
.verdict-go { background: #e8f5e9; color: #1b5e20; border-color: #bcdcc0; }
.verdict-pivot { background: #fdf3e7; color: #8a5a00; border-color: #e7d2b3; }
.verdict-nogo { background: #fdecea; color: #b3261e; border-color: #e7bcb6; }

.dossier-export { margin-top: 1rem; display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.dossier-export span { color: var(--muted); font-size: .9rem; }
.dossier-export .button-secondary { text-decoration: none; }
.dossier-dl { font-size: .8rem; font-weight: 600; color: var(--accent-strong); text-decoration: none; }

.dossier { margin-top: 1.4rem; padding-top: 1.2rem; border-top: 1px solid #efe9dd; }
.dossier-title { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); margin: 0 0 .8rem; }
.doc-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1rem 1.1rem;
  margin-bottom: .8rem;
  background: var(--surface);
}
.doc-card > header { display: flex; align-items: baseline; justify-content: space-between; gap: .8rem; flex-wrap: wrap; margin-bottom: .4rem; }
.doc-card > header h4 { margin: 0; font-size: 1.05rem; }
.doc-card > header span { color: var(--muted); font-size: .82rem; }
.doc-card > p { margin: 0 0 .6rem; color: var(--text); }
.evidence-grade { display: inline-block; margin: .15rem 0 .65rem; padding: .2rem .5rem; border-radius: 999px; background: #f1f3f5; color: #4b5563; font-size: .76rem; font-weight: 800; }
.evidence-explainer { margin: -.15rem 0 .85rem; color: var(--muted); font-size: .85rem; line-height: 1.4; }
.brochure-card { margin: 1.4rem 0; padding: 1.25rem; border: 1px solid #e2d8c8; border-radius: 18px; background: linear-gradient(135deg, #fffaf4, #fff); }
.brochure-card h3 { margin: .25rem 0 .35rem; }
.brochure-card p { margin: 0 0 .8rem; color: var(--muted); }
.brochure-card .button-primary:disabled { opacity: .48; cursor: not-allowed; transform: none; box-shadow: none; }
.brochure-controls { display: grid; grid-template-columns: 1fr 1fr auto; align-items: end; gap: .7rem; margin: 1rem 0; }
.brochure-controls label { display: grid; gap: .3rem; color: var(--muted); font-size: .82rem; font-weight: 700; }
.brochure-controls select { min-height: 42px; border: 1px solid var(--line); border-radius: 10px; padding: .5rem; background: #fff; }
.brochure-check { display: flex !important; grid-template-columns: auto 1fr; align-items: center; min-height: 42px; }
@media (max-width: 700px) { .brochure-controls { grid-template-columns: 1fr; } }

/* Home: promessa e CTA devono restare visibili nella prima schermata desktop. */
@media (min-width: 821px) {
  .landing-page .idea-hero .hero-copy { gap: 14px; transform: translateY(-18px); }
  .landing-page .idea-hero .hero-copy h1 {
    font-size: clamp(52px, 5.2vw, 76px);
    line-height: .98;
  }
  .landing-page .idea-hero .hero-copy p {
    font-size: clamp(17px, 1.45vw, 21px);
    line-height: 1.34;
  }
}

:where(a, button, select, summary, input, textarea):focus-visible {
  outline: 3px solid #176b56;
  outline-offset: 3px;
}
.doc-sub { margin-top: .5rem; }
.doc-sub h5 { margin: 0 0 .25rem; font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.doc-sub ul { margin: 0; padding-left: 1.1rem; display: flex; flex-direction: column; gap: .25rem; }
.doc-sub li { font-size: .92rem; }

.sources-block { margin-top: 1.2rem; padding-top: 1.2rem; border-top: 1px solid #efe9dd; }
.sources-block h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); margin: 0 0 .5rem; }
.sources-block ul { margin: 0; padding-left: 1.1rem; display: flex; flex-direction: column; gap: .3rem; }
.sources-block a { color: var(--accent-strong); word-break: break-all; }

/* ========================================================================
   LANDING · validazione evidence-first e passaggio controllato a OmniaOS
   ======================================================================== */
.validation-story {
  width: min(1440px, calc(100% - 64px));
  margin: 0 auto;
  padding: 92px 0 54px;
  border-top: 1px solid var(--border);
}

.validation-story > header {
  display: block;
}

.validation-story > header h2 {
  max-width: 1360px;
  margin: 0;
  color: var(--text);
  font-size: clamp(54px, 7.4vw, 118px);
  font-weight: 280;
  letter-spacing: -0.045em;
  line-height: 0.91;
}

.validation-story > header h2 span {
  color: var(--coral-red);
}

.validation-story > header p {
  max-width: 520px;
  margin: 28px 0 0;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.56;
}

.validation-story-steps {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 58px 0 0;
  padding: 0;
  list-style: none;
}

.validation-story-steps li {
  position: relative;
  display: grid;
  grid-template-rows: 64px auto;
  gap: 24px;
  min-width: 0;
  padding-right: 30px;
}

.validation-story-steps li::before {
  position: absolute;
  top: 31px;
  right: 0;
  left: 0;
  height: 1px;
  content: "";
  background: #58bd94;
}

.validation-story-steps li > span {
  z-index: 1;
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  color: #36a979;
  border: 1px solid #58bd94;
  border-radius: 50%;
  background: #ffffff;
  font-size: 28px;
  font-weight: 360;
}

.validation-story-steps li > div {
  min-height: 150px;
  padding-right: 24px;
  border-right: 1px solid var(--border);
}

.validation-story-steps li:last-child > div {
  border-right: 0;
}

.validation-story-steps h3,
.validation-story-handoff h3 {
  margin: 0;
  color: var(--text);
  font-weight: 340;
}

.validation-story-steps h3 {
  font-size: clamp(21px, 1.9vw, 30px);
  line-height: 1.08;
}

.validation-story-steps h3::after,
.validation-story-handoff h3::after {
  display: block;
  width: 40px;
  height: 3px;
  margin-top: 18px;
  content: "";
  background: var(--coral-red);
}

.validation-story-steps p,
.validation-story-handoff p {
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.5;
}

.validation-story-handoff {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin-top: 42px;
  border: 1px solid var(--border);
}

.validation-story-handoff > div,
.validation-story-handoff > a {
  min-height: 220px;
}

.validation-story-handoff > div {
  padding: 36px 42px;
  border-right: 1px solid var(--border);
}

.validation-story-handoff h3 {
  font-size: clamp(34px, 4vw, 62px);
  line-height: 1;
}

.validation-story-handoff > a {
  align-self: stretch;
  gap: 24px;
  margin: 32px;
  font-size: 20px;
}

.ecosystem-context {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  width: min(1440px, calc(100% - 64px));
  margin: 0 auto 70px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.ecosystem-context > * {
  margin: 0;
  padding: 24px 28px;
  color: var(--muted);
  border-right: 1px solid var(--border);
  line-height: 1.45;
}

.ecosystem-context > *:last-child {
  border-right: 0;
}

.ecosystem-context strong {
  color: var(--text);
}

.ecosystem-context__link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-width: 0;
  text-decoration: none;
  transition: color 160ms ease, background-color 160ms ease;
}

.ecosystem-context__link:hover {
  color: var(--text);
  background: #fff4f1;
}

.ecosystem-context__link:focus-visible {
  position: relative;
  z-index: 1;
  outline: 3px solid var(--coral-red);
  outline-offset: -3px;
}

.ecosystem-context__arrow {
  display: grid;
  flex: 0 0 52px;
  width: 52px;
  height: 52px;
  place-items: center;
  color: var(--coral-red);
  transition: transform 160ms ease;
}

.ecosystem-context__arrow svg {
  width: 44px;
  height: 44px;
}

.ecosystem-context__arrow path {
  fill: none;
  stroke: currentColor;
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ecosystem-context__link:hover .ecosystem-context__arrow,
.ecosystem-context__link:focus-visible .ecosystem-context__arrow {
  transform: translate(4px, -4px);
}

@media (max-width: 960px) {
  .validation-story > header {
    display: block;
  }

  .validation-story-steps {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 36px 0;
  }

  .validation-story-handoff {
    grid-template-columns: 1fr;
  }

  .validation-story-handoff > div {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
}

@media (max-width: 620px) {
  .validation-story,
  .ecosystem-context {
    width: calc(100% - 32px);
  }

  .validation-story {
    padding: 58px 0 36px;
  }

  .validation-story > header h2 {
    font-size: clamp(44px, 14vw, 66px);
    line-height: 0.94;
  }

  .validation-story-steps {
    grid-template-columns: 1fr;
    gap: 24px;
    margin-top: 40px;
  }

  .validation-story-steps li {
    grid-template-columns: 52px minmax(0, 1fr);
    grid-template-rows: auto;
    gap: 18px;
    padding: 0;
  }

  .validation-story-steps li::before {
    top: 52px;
    bottom: -24px;
    left: 25px;
    width: 1px;
    height: auto;
  }

  .validation-story-steps li:last-child::before {
    display: none;
  }

  .validation-story-steps li > span {
    width: 52px;
    height: 52px;
    font-size: 22px;
  }

  .validation-story-steps li > div {
    min-height: 0;
    padding: 0 0 22px;
    border-right: 0;
  }

  .validation-story-handoff > div {
    min-height: 0;
    padding: 28px 24px;
  }

  .validation-story-handoff > a {
    width: calc(100% - 36px);
    min-height: 64px;
    margin: 18px;
    font-size: 17px;
  }

  .ecosystem-context {
    grid-template-columns: 1fr;
    margin-bottom: 36px;
  }

  .ecosystem-context > * {
    padding: 18px 4px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .ecosystem-context > *:last-child {
    border-bottom: 0;
  }

  .ecosystem-context__link {
    gap: 16px;
  }

  .ecosystem-context__arrow {
    flex-basis: 44px;
    width: 44px;
    height: 44px;
  }

  .ecosystem-context__arrow svg {
    width: 38px;
    height: 38px;
  }
}

.realize-cta {
  margin-top: 1.2rem;
  padding: 1.1rem 1.2rem;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--accent);
  display: flex;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}
.realize-cta strong { display: block; font-size: 1.02rem; }
.realize-cta p { margin: .25rem 0 0; color: var(--muted); font-size: .92rem; max-width: 46ch; }
.realize-cta .button-primary { white-space: nowrap; text-decoration: none; }

/* Scheda di realizzazione: IdeeAI valida, FreeFuture valuta il preventivo. */
.quote-page {
  overflow: auto;
  color: var(--text);
  background: #f7f6f2;
}

.quote-shell {
  width: min(1180px, calc(100% - 48px));
  margin: 0 auto;
  padding: 54px 0 88px;
}

.quote-page .site-header .header-cta {
  grid-column: 3;
}

.quote-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(300px, .7fr);
  gap: 48px;
  align-items: end;
  padding: 34px 0 46px;
}

.quote-kicker,
.quote-section-heading > span,
.quote-run-link > span,
.quote-success > span {
  color: var(--coral-red);
  font-size: 12px;
  font-weight: 760;
  letter-spacing: .13em;
  text-transform: uppercase;
}

.quote-hero h1 {
  max-width: 820px;
  margin: 14px 0 0;
  font-size: clamp(44px, 6.4vw, 88px);
  font-weight: 720;
  line-height: .94;
  letter-spacing: -.055em;
}

.quote-hero-copy {
  display: grid;
  gap: 18px;
  padding-bottom: 5px;
}

.quote-hero-copy p,
.quote-hero-copy a,
.quote-run-link p,
.quote-success p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.quote-hero-copy a {
  color: var(--text);
  font-weight: 700;
  text-decoration: underline;
  text-decoration-color: var(--coral-red);
  text-underline-offset: 4px;
}

.quote-error,
.quote-run-link,
.quote-success {
  margin: 0 0 22px;
  padding: 22px 24px;
  border: 1px solid var(--border);
  background: #ffffff;
}

.quote-error {
  color: var(--danger);
  font-weight: 700;
  border-color: rgba(182, 69, 60, .45);
}

.quote-run-link {
  display: grid;
  grid-template-columns: auto auto minmax(240px, 1fr);
  gap: 18px;
  align-items: center;
}

.quote-success {
  max-width: 760px;
  padding: 42px;
}

.quote-success h2 {
  margin: 12px 0 14px;
  font-size: clamp(32px, 5vw, 56px);
  line-height: 1;
}

.quote-success .button-primary {
  margin-top: 24px;
}

.quote-form {
  display: grid;
  gap: 1px;
  border: 1px solid var(--border);
  background: var(--border);
}

.quote-form-section {
  display: grid;
  grid-template-columns: minmax(220px, .36fr) minmax(0, 1fr);
  gap: 38px;
  padding: 34px;
  background: #ffffff;
}

.quote-section-heading {
  display: grid;
  align-content: start;
  gap: 10px;
}

.quote-section-heading h2,
.quote-section-heading p {
  margin: 0;
}

.quote-section-heading h2 {
  font-size: 28px;
  line-height: 1.05;
}

.quote-section-heading p {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.48;
}

.quote-field-grid {
  display: grid;
  gap: 18px;
}

.quote-field-grid.two-columns {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.quote-field,
.quote-priorities {
  display: grid;
  gap: 8px;
  min-width: 0;
  font-weight: 700;
}

.quote-field > span,
.quote-priorities legend {
  font-size: 13px;
}

.quote-field input,
.quote-field textarea,
.quote-field select {
  width: 100%;
  min-width: 0;
  padding: 13px 14px;
  color: var(--text);
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
  font-weight: 430;
  line-height: 1.45;
}

.quote-field input:focus,
.quote-field textarea:focus,
.quote-field select:focus {
  border-color: var(--accent-strong);
  box-shadow: 0 0 0 3px rgba(23, 107, 86, .12);
}

.quote-field textarea {
  resize: vertical;
}

.quote-field.compact {
  align-content: start;
}

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

.quote-priorities {
  grid-column: 2;
  margin: 4px 0 0;
  padding: 0;
  border: 0;
}

.quote-priorities > div {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.quote-priorities label {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 13px;
  font-weight: 620;
}

.quote-priorities input {
  width: 17px;
  height: 17px;
  accent-color: var(--accent-strong);
}

.quote-submit {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px 28px;
  align-items: center;
  padding: 26px 34px;
  background: #111312;
  color: #ffffff;
}

.quote-submit strong,
.quote-submit p,
.quote-submit small {
  margin: 0;
}

.quote-submit p,
.quote-submit small {
  color: rgba(255, 255, 255, .72);
}

.quote-submit p {
  margin-top: 4px;
}

.quote-submit small {
  grid-column: 1 / -1;
}

.quote-submit small a {
  color: #ffffff;
  text-decoration: underline;
}

@media (max-width: 820px) {
  .quote-page {
    overflow: auto;
  }

  .quote-shell {
    width: min(100% - 28px, 680px);
    padding: 24px 0 88px;
  }

  .quote-page .site-header .header-cta {
    display: inline-flex !important;
    grid-column: 2;
    grid-row: 1;
    width: auto;
  }

  .quote-hero,
  .quote-form-section,
  .quote-run-link,
  .quote-submit {
    grid-template-columns: 1fr;
  }

  .quote-hero {
    gap: 22px;
    padding: 22px 0 32px;
  }

  .quote-hero h1 {
    font-size: clamp(40px, 13vw, 64px);
  }

  .quote-form-section {
    gap: 24px;
    padding: 24px 20px;
  }

  .quote-field-grid.two-columns,
  .quote-priorities > div {
    grid-template-columns: 1fr;
  }

  .quote-priorities {
    grid-column: 1;
  }

  .quote-submit {
    padding: 24px 20px;
  }

  .quote-submit .button-primary {
    width: 100%;
  }
}

.clarify-button { margin: .8rem 0 0; cursor: pointer; }
.clarify-box {
  margin-top: 1rem;
  padding: 1rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-muted);
  display: flex;
  flex-direction: column;
  gap: .9rem;
}
.clarify-hint { margin: 0; color: var(--muted); font-size: .9rem; }
.clarify-q { display: flex; flex-direction: column; gap: .35rem; font-weight: 600; }
.clarify-q span { font-size: .95rem; }
.clarify-q textarea {
  font: inherit;
  font-weight: 400;
  padding: .6rem .8rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  resize: vertical;
  background: var(--surface);
  color: var(--text);
}

@media (min-width: 720px) {
  .result-grid { grid-template-columns: 1fr 1fr; }
}

/* ========================================================================
   §9 · TAVOLO v2 — layout 2 colonne + conversazione (chat)
   ======================================================================== */

/* Layout: regia a sinistra + conversazione a destra (via la colonna preview) */
.app-shell--2col {
  grid-template-columns: 300px minmax(0, 1fr);
}
.workbench--chat {
  grid-template-rows: auto minmax(0, 1fr) auto;
}

/* Sidebar — costo dal vivo (prominente) */
.cost-live {
  gap: 4px;
  padding: 12px 13px;
  border: 1px solid #cfe6db;
  border-radius: 10px;
  background: var(--accent);
}
.cost-head {
  font-size: 11px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent-strong);
}
.cost-main {
  font-size: 20px;
  font-weight: 680;
  color: var(--text);
}
.cost-main .cost-euro {
  margin-left: 5px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
}
.cost-sub {
  font-size: 12px;
  color: var(--muted);
}

/* Sidebar — selettore motore più grande */

/* Conversazione */
.conversation {
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
  padding: 24px 28px;
}
.msg {
  display: flex;
  flex-direction: column;
  max-width: 760px;
}
.msg-user {
  align-self: flex-end;
  align-items: flex-end;
}
.msg-assistant {
  align-self: flex-start;
  align-items: flex-start;
}
.msg-author {
  margin-bottom: 4px;
  font-size: 12px;
  font-weight: 650;
  color: var(--muted);
}
.msg-body {
  padding: 12px 15px;
  border-radius: 12px;
  line-height: 1.5;
}
.msg-assistant .msg-body {
  background: #ffffff;
  border: 1px solid var(--border);
}
.msg-user .msg-body {
  background: var(--accent);
  border: 1px solid #cfe6db;
}
.msg-body p {
  margin: 0;
}
.msg-body p + p {
  margin-top: 8px;
}

/* Stato "sta ragionando" */
.thinking-line {
  display: flex;
  align-items: center;
  color: var(--muted);
}
.spinner {
  display: inline-block;
  width: 13px;
  height: 13px;
  margin-right: 9px;
  border: 2px solid var(--border);
  border-top-color: var(--accent-strong);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Form delle domande (clarifier) come card */
.clarify-form {
  display: flex;
  flex-direction: column;
  max-width: 580px;
  padding: 14px 16px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 12px;
}
.clarify-form .msg-body {
  padding: 0;
  border: 0;
  background: none;
}
.clarify-fields {
  display: flex;
  flex-direction: column;
  gap: 11px;
  margin-top: 12px;
}
.cq {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.cq span {
  font-size: 14px;
  color: var(--text);
}
.clarify-input {
  width: 100%;
  min-height: 38px;
  padding: 8px 11px;
  font: inherit;
  border: 1px solid var(--border);
  border-radius: 9px;
  outline: none;
}
.clarify-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 14px;
}
.clarify-done {
  opacity: 0.65;
}
.btn-primary-sm {
  min-height: 38px;
  padding: 0 16px;
  font-weight: 600;
  color: #ffffff;
  background: var(--text);
  border: 1px solid var(--text);
  border-radius: 9px;
  cursor: pointer;
}
.btn-link {
  padding: 0;
  font: inherit;
  color: var(--muted);
  background: none;
  border: 0;
  text-decoration: underline;
  cursor: pointer;
}

/* Risultato: verdetto + campi + dossier */
.msg-result .msg-body {
  max-width: 640px;
}
.vbadge {
  display: inline-block;
  margin-bottom: 10px;
  padding: 5px 12px;
  font-size: 14px;
  font-weight: 680;
  border-radius: 999px;
}
.vbadge-go {
  color: #1b5e20;
  background: #e8f5e9;
  border: 1px solid #bcdcc0;
}
.vbadge-pivot {
  color: #8a5a00;
  background: #fdf3e7;
  border: 1px solid #e7d2b3;
}
.vbadge-nogo {
  color: #b3261e;
  background: #fdecea;
  border: 1px solid #e7bcb6;
}
.result-dir {
  margin: 0 0 10px;
  font-size: 16px;
  font-weight: 680;
  line-height: 1.35;
}
.result-field {
  margin: 12px 0 0;
  line-height: 1.5;
}
.result-label {
  display: block;
  margin-bottom: 2px;
  font-size: 11px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
}
.dossier-card {
  margin-top: 14px;
  padding: 12px 14px;
  background: var(--rail-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.dossier-card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 10px;
}
.dossier-card-head b {
  font-size: 14px;
}
.dossier-card-head span {
  font-size: 12px;
  color: var(--muted);
}
.dossier-card-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.btn-secondary-sm {
  padding: 7px 13px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 8px;
}

/* Composer a tutta larghezza in basso */
.composer--chat {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  padding: 14px 28px 18px;
  background: #ffffff;
  border-top: 1px solid var(--border);
}
.composer--chat textarea {
  flex: 1;
  resize: none;
  min-height: 46px;
  max-height: 160px;
  padding: 12px 14px;
  font: inherit;
  line-height: 1.4;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  outline: none;
}
.composer--chat button {
  min-height: 46px;
  padding: 0 22px;
  font-weight: 600;
  color: #ffffff;
  background: var(--coral-red);
  border: 1px solid var(--coral-red);
  border-radius: 12px;
  cursor: pointer;
}
.composer--chat button:disabled,
.composer--chat textarea:disabled {
  opacity: 0.55;
  cursor: default;
}

/* Mobile: una colonna; la regia (sidebar) diventa un drawer a scomparsa */
.rail-toggle,
.rail-backdrop {
  display: none;
}
@media (max-width: 820px) {
  .app-shell--2col {
    grid-template-columns: 1fr;
  }
  .app-shell--2col .left-rail {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 86%;
    max-width: 320px;
    z-index: 60;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.28);
  }
  .app-shell--2col .left-rail.open {
    transform: translateX(0);
  }
  .rail-toggle {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 999px;
    cursor: pointer;
  }
  .rail-backdrop.show {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 50;
    background: rgba(18, 24, 20, 0.4);
  }
  .topbar--chat .workspace-label {
    display: none;
  }
  .conversation {
    padding: 16px 14px;
  }
  .composer--chat {
    padding: 12px 14px calc(14px + env(safe-area-inset-bottom));
  }
}

/* ========================================================================
   §10 · Engine switch (GPT ⇄ Claude) nella topbar
   ======================================================================== */
.topbar--chat {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
}
.topbar--chat .topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-self: end;
}
.engine-switch {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  background: #efefeb;
  border: 1px solid var(--border);
  border-radius: 999px;
}
.engine-btn {
  padding: 6px 15px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
}
.engine-btn.active {
  color: #ffffff;
  background: var(--coral-red);
}
.engine-btn.active.running {
  animation: enginePulse 1.2s ease-in-out infinite;
}
@keyframes enginePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(216, 90, 70, 0.5); }
  50% { box-shadow: 0 0 0 6px rgba(216, 90, 70, 0); }
}

@media (max-width: 820px) {
  .topbar--chat {
    display: flex;
    flex-wrap: wrap;
  }
  .topbar--chat .topbar-right {
    margin-left: auto;
  }
  .engine-switch {
    order: 3;
    width: 100%;
    justify-content: center;
  }
}

/* ========================================================================
   §11 · Consiglio (agenti): infrastruttura bloccata + specialisti on/off
   ======================================================================== */
.council-group {
  display: grid;
  gap: 7px;
}
.council-group + .council-group {
  margin-top: 13px;
}
.council-group-label {
  font-size: 11px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
}
.cagent-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 28px;
}
.cagent-name {
  font-size: 13px;
  color: var(--text);
}
.switch {
  position: relative;
  flex: none;
  width: 38px;
  height: 21px;
  padding: 0;
  background: #cdd2cd;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease;
}
.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 17px;
  height: 17px;
  background: #ffffff;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  transition: transform 0.15s ease;
}
.switch.on {
  background: var(--blue-strong);
}
.switch.on::after {
  transform: translateX(17px);
}
.switch.locked {
  cursor: default;
}

/* Costo visibile su mobile (la sidebar è nascosta sotto 820px) */
.mobile-cost {
  display: none;
}
@media (max-width: 820px) {
  .mobile-cost {
    display: block;
    padding: 9px 14px;
    font-size: 12.5px;
    font-weight: 600;
    text-align: center;
    color: var(--accent-strong);
    background: var(--accent);
    border-top: 1px solid #cfe6db;
  }
}

/* ========================================================================
   §12 · Pagina Processo — passi ad accordion
   ======================================================================== */
.process-steps {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 760px;
}
.step {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 12px;
}
.step > summary {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 15px 18px;
  cursor: pointer;
  list-style: none;
}
.step > summary::-webkit-details-marker {
  display: none;
}
.step-num {
  min-width: 22px;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}
.step > summary strong {
  font-size: 17px;
  font-weight: 700;
}
.step-tag {
  margin-left: auto;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}
.step-chevron {
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  transition: transform 0.2s ease;
}
.step[open] .step-chevron {
  transform: rotate(-135deg);
}
.step-body {
  padding: 0 18px 16px 54px;
}
.step-body p {
  margin: 0;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
}
@media (max-width: 600px) {
  .step-body {
    padding: 0 16px 14px 16px;
  }
}

/* ========================================================================
   §13 · WORKSPACE UNIFICATO — Tavolo, Run, Archivio e Profilo
   ======================================================================== */
.workspace-page {
  min-height: 100vh;
  overflow: auto;
  color: var(--text);
  background: #ffffff;
}

.workspace-header {
  position: sticky;
  top: 0;
  z-index: 40;
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr) auto;
  align-items: center;
  min-height: 64px;
  padding: 10px 24px;
  background: #ffffff;
  border-bottom: 1px solid var(--border);
}

.workspace-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  width: fit-content;
  font-size: 16px;
  font-weight: 760;
}

.workspace-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.workspace-nav a {
  padding: 8px 11px;
  color: var(--muted);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 680;
}

.workspace-nav a:hover,
.workspace-nav a[aria-current="page"] {
  color: var(--text);
  background: var(--surface-muted);
}

.workspace-actions {
  display: flex;
  align-items: center;
  justify-content: end;
  gap: 8px;
}

.workspace-actions form {
  margin: 0;
}

.workspace-credit,
.workspace-logout {
  min-height: 38px;
  padding: 0 13px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 720;
}

.workspace-credit {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: #9b3428;
  background: #fff0ed;
  border: 1px solid #efb3aa;
}

.workspace-logout {
  color: var(--text);
  background: #ffffff;
  border: 1px solid var(--border);
}

.workspace-credit:hover {
  background: #ffe4df;
}

.workspace-logout:hover {
  background: var(--surface-muted);
}

.workspace-layout {
  display: grid;
  grid-template-columns: 238px minmax(0, 1fr) 320px;
  align-items: start;
  max-width: 1440px;
  min-height: calc(100vh - 64px);
  margin: 0 auto;
  border-inline: 1px solid var(--border);
}

.workspace-layout > * {
  min-width: 0;
}

.workspace-rail,
.workspace-preview {
  align-self: stretch;
  min-height: calc(100vh - 64px);
  padding: 22px 18px;
  background: #fbfbfa;
}

.workspace-rail {
  border-right: 1px solid var(--border);
}

.workspace-preview {
  border-left: 1px solid var(--border);
}

.workspace-sticky {
  position: sticky;
  top: 86px;
  display: grid;
  gap: 18px;
}

.workspace-canvas {
  padding: 30px clamp(24px, 3vw, 48px) 80px;
  background: #ffffff;
}

.workspace-title {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.workspace-title h1,
.workspace-title p {
  margin: 0;
}

.workspace-title h1 {
  font-size: clamp(28px, 3vw, 42px);
  line-height: 1.05;
}

.workspace-title p {
  max-width: 660px;
  margin-top: 9px;
  color: var(--muted);
  line-height: 1.5;
}

.rail-heading {
  display: grid;
  gap: 4px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.rail-heading span,
.preview-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 760;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.rail-heading strong {
  font-size: 24px;
}

.workspace-steps {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.workspace-steps li {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 10px;
  align-items: start;
  padding: 10px;
  border-radius: 9px;
}

.workspace-steps li.active {
  background: var(--accent);
}

.workspace-steps li > span {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  color: var(--muted);
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 50%;
  font-size: 11px;
  font-weight: 800;
}

.workspace-steps li div {
  display: grid;
  gap: 2px;
}

.workspace-steps strong {
  font-size: 13px;
}

.workspace-steps small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.rail-control {
  display: grid;
  gap: 7px;
}

.rail-control > span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 760;
  text-transform: uppercase;
}

.rail-control .mode-switch {
  grid-template-columns: 1fr;
  gap: 4px;
  padding: 4px;
}

.rail-control .mode-switch button {
  text-align: left;
}

.rail-note,
.preview-note {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.rail-link {
  display: inline-flex;
  width: fit-content;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 720;
}

.canvas-section {
  padding: 28px 0;
  border-bottom: 1px solid var(--border);
}

.section-title-row {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.section-title-row > div {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.section-title-row span,
.section-title-row small {
  color: var(--muted);
  font-size: 11px;
}

.section-title-row h2 {
  margin: 0;
  font-size: 20px;
}

.workspace-canvas .field-label {
  margin-top: 0;
}

.workspace-canvas #commandInput {
  min-height: 190px;
  border-radius: 10px;
}

.workspace-canvas .validation-mode-list {
  margin-bottom: 0;
}

.workspace-canvas .validation-mode-card {
  border-radius: 10px;
}

.preview-panel {
  display: grid;
  gap: 14px;
  padding: 18px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.preview-panel h2,
.preview-panel p {
  margin: 0;
}

.preview-panel h2 {
  font-size: 22px;
}

.preview-panel > p:not(.form-error):not(.preview-note) {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.preview-facts {
  display: grid;
  margin: 0;
  border-block: 1px solid var(--border);
}

.preview-facts div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 11px 0;
  border-bottom: 1px solid #ecece8;
}

.preview-facts div:last-child {
  border-bottom: 0;
}

.preview-facts dt {
  color: var(--muted);
  font-size: 12px;
}

.preview-facts dd {
  margin: 0;
  font-size: 17px;
  font-weight: 800;
}

.workspace-preview .launch-button {
  width: 100%;
  min-height: 48px;
}

.preview-safety {
  display: grid;
  gap: 3px;
  padding-top: 13px;
  border-top: 1px solid var(--border);
}

.preview-safety strong {
  font-size: 12px;
}

.preview-safety span {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

/* Run */
.run-nav {
  display: grid;
  gap: 4px;
}

.run-nav a {
  padding: 9px 10px;
  color: var(--muted);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 680;
}

.run-nav a:hover {
  color: var(--text);
  background: var(--surface-muted);
}

.run-rail .run-status {
  justify-content: center;
  width: 100%;
}

.rail-timeline {
  display: grid;
  gap: 9px;
}

.rail-timeline h2 {
  margin: 0;
  font-size: 13px;
}

.rail-timeline .timeline {
  display: grid;
  gap: 7px;
  max-height: 340px;
  overflow-y: auto;
}

.rail-timeline .event-row {
  grid-template-columns: 46px 1fr;
  padding: 9px;
  font-size: 11px;
}

.run-title {
  align-items: end;
}

.run-title .dossier-export {
  flex-wrap: nowrap;
  margin: 0;
}

.run-canvas .result-panel {
  margin: 24px 0 0;
  padding: 0;
  border: 0;
  border-radius: 0;
}

.run-canvas .result-panel > h2 {
  font-size: clamp(26px, 3vw, 40px);
  line-height: 1.08;
}

.final-move {
  color: var(--text);
  font-size: 18px;
  line-height: 1.45;
}

.run-preview .workspace-sticky {
  gap: 14px;
}

.run-preview .brochure-card {
  margin: 0;
  padding: 14px 0 0;
  background: transparent;
  border: 0;
  border-top: 1px solid var(--border);
  border-radius: 0;
}

.run-preview .brochure-card h3 {
  font-size: 15px;
}

.run-preview .brochure-controls {
  grid-template-columns: 1fr;
  margin: 8px 0 12px;
}

.run-preview .brochure-card .button-primary,
.run-preview .next-prompt .button-secondary,
.run-preview .realize-cta .button-primary {
  width: 100%;
}

.saved-brochures {
  display: grid;
  gap: 8px;
  padding: 12px 0;
  border-block: 1px solid var(--border);
}

.saved-brochures > strong {
  font-size: 12px;
}

.saved-brochures article {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 9px;
  background: var(--accent);
  border-radius: 8px;
}

.saved-brochures article div {
  display: grid;
  gap: 2px;
}

.saved-brochures span,
.saved-brochures a,
.saved-brochures em {
  font-size: 11px;
  font-weight: 720;
}

.saved-brochures small {
  color: var(--muted);
  font-size: 10px;
}

.saved-brochures a {
  color: var(--accent-strong);
}

.run-preview .realize-cta {
  display: grid;
  margin: 0;
  padding: 16px;
  border-radius: 10px;
}

/* Archivio */
.workspace-page .archive-shell {
  padding: 30px 24px 80px;
}

.archive-page-head,
.account-page-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  max-width: 1320px;
  margin: 0 auto 20px;
}

.archive-page-head h1,
.archive-page-head p,
.account-page-head h1,
.account-page-head p {
  margin: 0;
}

.archive-page-head h1,
.account-page-head h1 {
  font-size: clamp(32px, 4vw, 48px);
  line-height: 1.05;
}

.archive-page-head p,
.account-page-head p {
  margin-top: 7px;
  color: var(--muted);
}

.archive-page-head .primary-link {
  min-height: 42px;
  color: #ffffff;
  background: var(--text);
  border-radius: 8px;
}

.archive-assets {
  max-width: 1320px;
  margin: 0 auto 16px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #ffffff;
}

.archive-assets-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 12px;
}

.archive-assets-head h2,
.archive-assets-head p {
  margin: 0;
}

.archive-assets-head h2 {
  font-size: 18px;
}

.archive-assets-head p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.archive-assets-head > span {
  display: grid;
  place-items: center;
  min-width: 34px;
  height: 34px;
  color: var(--accent-strong);
  background: var(--accent);
  border-radius: 50%;
  font-weight: 800;
}

.brochure-library {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 10px;
}

.brochure-library-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  background: #fbfbfa;
  border: 1px solid var(--border);
  border-radius: 9px;
}

.brochure-library-item > div {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.brochure-library-item span,
.brochure-library-item small {
  color: var(--muted);
  font-size: 11px;
}

.brochure-library-item strong {
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brochure-library-item .button-secondary {
  min-height: 36px;
  padding: 0 11px;
  font-size: 12px;
}

.workspace-page .archive-detail {
  top: 82px;
}

.detail-brochures {
  display: grid;
  gap: 7px;
}

.detail-brochures article {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  background: var(--accent);
  border-radius: 8px;
}

.detail-brochures article div {
  display: grid;
  gap: 2px;
}

.detail-brochures strong,
.detail-brochures a,
.detail-brochures span {
  font-size: 12px;
}

.detail-brochures small {
  color: var(--muted);
  font-size: 10px;
}

.detail-brochures a {
  color: var(--accent-strong);
  font-weight: 750;
}

/* Profilo */
.account-shell {
  max-width: 1120px;
  margin: 0 auto;
  padding: 34px 24px 90px;
}

.account-page-head {
  max-width: none;
  margin-bottom: 24px;
}

.account-page-head .button-secondary {
  min-height: 42px;
}

.account-notice {
  margin: 0 0 18px;
  padding: 13px 15px;
  border: 1px solid;
  border-radius: 9px;
  font-weight: 650;
}

.account-notice-success {
  color: #145b3d;
  background: #edf8f2;
  border-color: #a8d8c2;
}

.account-notice-wait {
  color: #7a5b16;
  background: #fff8e7;
  border-color: #e4d29d;
}

.account-notice-error {
  color: #862319;
  background: #fff2ef;
  border-color: #efb3aa;
}

.account-overview {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 14px;
}

.account-identity-card,
.account-balance-card,
.account-section,
.account-archive-callout {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #ffffff;
}

.account-identity-card,
.account-balance-card {
  padding: 20px;
}

.account-identity-card > span,
.account-balance-card > span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 760;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.account-identity-card h2 {
  margin: 10px 0 5px;
  font-size: 22px;
  overflow-wrap: anywhere;
}

.account-identity-card p,
.account-balance-card p {
  margin: 0;
  color: var(--muted);
}

.account-identity-card em {
  display: inline-block;
  margin-top: 13px;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 720;
  font-style: normal;
}

.account-balance-card {
  color: #742a21;
  background: #fff0ed;
  border-color: #efb3aa;
}

.account-balance-card strong {
  line-height: 1;
}

.account-balance-card a {
  display: inline-flex;
  margin-top: 15px;
  font-size: 12px;
  font-weight: 800;
}

.account-balance-card .availability-intro {
  margin-top: 10px;
  font-size: 12px;
  line-height: 1.4;
}

.account-availability {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
  margin-top: 13px;
}

.account-availability div {
  display: grid;
  gap: 4px;
  padding: 10px 8px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(155, 52, 40, 0.2);
  border-radius: 8px;
}

.account-availability strong {
  display: block;
  font-size: 25px;
}

.account-availability small {
  color: var(--muted);
  font-size: 9px;
  line-height: 1.2;
}

.account-section {
  margin-top: 18px;
  padding: 20px;
}

.account-section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 16px;
}

.account-section-head h2,
.account-section-head p {
  margin: 0;
}

.account-section-head p,
.account-section-head small,
.account-muted {
  color: var(--muted);
}

.account-section-head p {
  margin-top: 4px;
}

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

.credit-package {
  display: grid;
  justify-items: start;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 9px;
}

.credit-package > span,
.credit-package > small,
.credit-package > em {
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
}

.credit-package > strong {
  margin-top: 9px;
  font-size: 32px;
  line-height: 1;
}

.credit-package > strong.purchase-name {
  min-height: 52px;
  font-size: 21px;
  line-height: 1.18;
}

.credit-package > p {
  min-height: 58px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.credit-package > b {
  margin-top: 12px;
  font-size: 14px;
}

.credit-package form,
.credit-package button {
  width: 100%;
}

.credit-package form {
  margin-top: 14px;
}

.credit-package button {
  min-height: 40px;
  border: 0;
}

.account-archive-callout {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-top: 18px;
  padding: 18px 20px;
  background: var(--accent);
  border-color: #b8d6c9;
}

.account-archive-callout h2,
.account-archive-callout p {
  margin: 0;
}

.account-archive-callout h2 {
  font-size: 18px;
}

.account-archive-callout p {
  margin-top: 4px;
  color: var(--muted);
}

.account-archive-callout .button-primary {
  white-space: nowrap;
}

.account-danger p {
  color: var(--muted);
}

.account-danger form {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 12px;
}

.account-danger input {
  min-height: 40px;
  padding: 0 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.account-danger button {
  min-height: 40px;
  padding: 0 13px;
  color: #9b3428;
  background: #fff0ed;
  border: 1px solid #efb3aa;
  border-radius: 8px;
  font-weight: 720;
}

@media (max-width: 1100px) {
  .workspace-layout {
    grid-template-columns: 220px minmax(0, 1fr);
  }

  .workspace-preview {
    grid-column: 2;
    min-height: auto;
    border-top: 1px solid var(--border);
    border-left: 0;
  }

  .workspace-preview .workspace-sticky {
    position: static;
  }

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

@media (max-width: 820px) {
  .workspace-header {
    grid-template-columns: 1fr auto;
    gap: 8px;
    padding: 9px 14px;
  }

  .workspace-nav {
    display: none;
  }

  .workspace-actions {
    grid-column: 2;
  }

  .workspace-credit,
  .workspace-logout {
    min-height: 34px;
    padding: 0 9px;
    font-size: 11px;
  }

  .workspace-layout {
    display: block;
    border-inline: 0;
  }

  .workspace-rail,
  .workspace-preview {
    min-height: 0;
    padding: 18px 16px;
    border: 0;
    border-bottom: 1px solid var(--border);
  }

  .workspace-sticky {
    position: static;
  }

  .workspace-steps,
  .rail-note,
  .run-nav {
    display: none;
  }

  .workspace-canvas {
    padding: 24px 16px 48px;
  }

  .workspace-title,
  .section-title-row,
  .archive-page-head,
  .account-page-head,
  .account-section-head,
  .account-archive-callout {
    align-items: start;
    flex-direction: column;
  }

  .validation-mode-list,
  .account-overview,
  .credit-packages {
    grid-template-columns: 1fr;
  }

  .run-title .dossier-export {
    flex-wrap: wrap;
  }

  .workspace-page .archive-shell,
  .account-shell {
    padding: 24px 16px 90px;
  }

  .archive-toolbar {
    grid-template-columns: 1fr;
  }

  .archive-grid {
    grid-template-columns: 1fr;
  }

  .workspace-page .archive-detail {
    position: static;
  }

  .brochure-library-item,
  .detail-brochures article {
    grid-template-columns: 1fr;
  }

  .account-danger form {
    align-items: stretch;
    flex-direction: column;
  }
}

/* ========================================================================
   §11 · ARCHIVIO IDEA-FIRST — una card, tutti gli output
   ======================================================================== */

.archive-card {
  grid-template-columns: minmax(0, 1fr) 158px;
  gap: 0;
  padding: 0;
  overflow: hidden;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.archive-card:hover {
  border-color: #b8c1b9;
  box-shadow: 0 10px 26px rgba(18, 24, 20, 0.06);
}

.archive-card.selected {
  background: #ffffff;
  border-color: #9bc8b6;
  box-shadow: inset 3px 0 0 var(--accent-strong);
}

.archive-card-main {
  display: grid;
  gap: 8px;
  width: 100%;
  padding: 16px 16px 14px;
  color: var(--text);
  text-align: left;
  background: transparent;
  border: 0;
}

.archive-card-main:focus-visible {
  outline: 3px solid rgba(61, 111, 224, 0.25);
  outline-offset: -3px;
}

.archive-card-main > strong {
  font-size: 18px;
  line-height: 1.22;
  letter-spacing: -0.02em;
}

.archive-card-description {
  display: -webkit-box;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.archive-card-main > small {
  margin-top: 2px;
}

.archive-card-actions,
.detail-output-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.archive-card-actions {
  flex-direction: column;
  justify-content: center;
  padding: 10px 12px;
  background: #f8f9f7;
  border-left: 1px solid var(--border);
}

.archive-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 10px;
  color: var(--text);
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 11px;
  font-weight: 760;
  line-height: 1.2;
  text-align: center;
}

.archive-card-actions .archive-action {
  width: 100%;
}

a.archive-action:hover {
  border-color: #929a92;
}

.archive-action-primary {
  color: #ffffff;
  background: var(--text);
  border-color: var(--text);
}

a.archive-action-primary:hover {
  background: #303431;
  border-color: #303431;
}

.archive-action-brochure {
  color: var(--accent-strong);
  background: var(--accent);
  border-color: #b8d6c9;
}

.archive-action-progress {
  color: #7a5b16;
  background: #fff8e7;
  border-color: #e4d29d;
}

.archive-action-disabled {
  color: #7b817a;
  background: #f0f1ef;
  border-color: #e0e2de;
}

.detail-output-actions {
  padding: 12px 0 4px;
  border-bottom: 1px solid var(--border);
}

.archive-output-note {
  color: var(--muted);
  font-size: 12px;
}

.workspace-page .archive-detail .detail-head h2 {
  max-width: 580px;
  font-size: clamp(22px, 3vw, 30px);
  line-height: 1.14;
  letter-spacing: -0.025em;
}

.detail-brochures .archive-action {
  justify-self: start;
}

@media (max-width: 700px) {
  .archive-card {
    grid-template-columns: 1fr;
  }

  .archive-card-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    border-top: 1px solid var(--border);
    border-left: 0;
  }

  .archive-card-actions .archive-action-primary {
    grid-column: 1 / -1;
  }

  .archive-action {
    min-height: 38px;
    padding-inline: 8px;
  }

  .detail-output-actions {
    display: grid;
    grid-template-columns: 1fr;
  }
}

/* ========================================================================
   §14 · WORKSPACE OUTPUT UNICO — contenuto variabile, orientamento stabile
   ======================================================================== */

.output-panel[hidden] {
  display: none !important;
}

#outputDownload[hidden] {
  display: none !important;
}

.workspace-view-tab.is-active {
  color: var(--accent-strong);
  background: var(--accent);
  border-color: #91c3ad;
  box-shadow: inset 0 -3px 0 var(--accent-strong);
}

.workspace-view-tab.run-quote-action.is-active {
  color: #76261d;
  background: #ffe3dd;
  border-color: #e99083;
  box-shadow: inset 0 -3px 0 var(--coral-red);
}

.run-relation-document {
  width: 100%;
  margin-top: 0;
}

.run-relation-document .relation-lead {
  padding-top: 48px;
}

.run-brochure-panel,
.run-quote-panel {
  padding-top: 24px;
}

.run-brochure-panel .brochure-layout {
  margin-top: 0;
}

.workspace-empty-copy {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.run-quote-panel {
  width: min(820px, 100%);
}

.workspace-quote-intro,
.workspace-quote-success {
  padding: 34px 0 30px;
  border-bottom: 1px solid var(--border);
}

.workspace-quote-intro h2,
.workspace-quote-success h2 {
  max-width: 720px;
  margin: 10px 0 0;
  font-size: clamp(30px, 4vw, 46px);
  line-height: 1.05;
  letter-spacing: -.035em;
}

.workspace-quote-intro p,
.workspace-quote-success p {
  max-width: 680px;
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.6;
}

.workspace-quote-success .button-primary {
  display: inline-flex;
  margin-top: 22px;
}

.workspace-form-error {
  margin: 20px 0 0;
  padding: 12px 14px;
  color: #862319;
  background: #fff2ef;
  border: 1px solid #efb3aa;
  border-radius: 8px;
  font-weight: 700;
}

.workspace-quote-form {
  display: grid;
  gap: 18px;
  padding: 28px 0 64px;
}

.workspace-quote-brief {
  display: grid;
  gap: 18px;
  padding: 20px;
  background: #f5faf7;
  border: 1px solid #bfdccd;
  border-radius: 10px;
}

.workspace-quote-brief-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 20px;
}

.workspace-quote-brief-head > div {
  display: grid;
  gap: 6px;
}

.workspace-quote-brief-head span {
  color: var(--accent-strong);
  font-size: 10px;
  font-weight: 820;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.workspace-quote-brief-head h3 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
}

.workspace-quote-brief-head > strong {
  flex: none;
  padding: 7px 9px;
  color: var(--accent-strong);
  background: #dff1e9;
  border: 1px solid #b8d9cb;
  border-radius: 999px;
  font-size: 10px;
}

.workspace-quote-brief dl {
  display: grid;
  gap: 0;
  margin: 0;
  border-top: 1px solid #cfe2d8;
}

.workspace-quote-brief dl > div {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 18px;
  padding: 13px 0;
  border-bottom: 1px solid #cfe2d8;
}

.workspace-quote-brief dt {
  color: var(--accent-strong);
  font-size: 11px;
  font-weight: 800;
}

.workspace-quote-brief dd,
.workspace-quote-brief > p {
  margin: 0;
  color: #465149;
  font-size: 12px;
  line-height: 1.55;
}

.workspace-quote-brief > p {
  color: var(--muted);
  font-size: 11px;
}

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

.workspace-quote-form label {
  display: grid;
  gap: 7px;
  color: var(--text);
  font-size: 12px;
  font-weight: 780;
}

.workspace-quote-form input,
.workspace-quote-form textarea,
.workspace-quote-form select {
  width: 100%;
  padding: 12px 13px;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 9px;
  font: inherit;
  font-size: 14px;
  font-weight: 450;
}

.workspace-quote-form textarea {
  min-height: 170px;
  resize: vertical;
  line-height: 1.5;
}

.workspace-quote-form input:focus,
.workspace-quote-form textarea:focus,
.workspace-quote-form select:focus {
  outline: 3px solid rgba(39, 126, 94, .14);
  border-color: #7db79f;
}

.workspace-quote-submit {
  display: flex;
  align-items: center;
  gap: 18px;
}

.workspace-quote-submit .button-primary {
  flex: none;
  border: 0;
  cursor: pointer;
}

.workspace-quote-submit p {
  max-width: 460px;
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

@media (max-width: 1240px) {
  .run-workspace-focused .run-title {
    grid-template-columns: 1fr;
  }

  .run-workspace-focused .run-title .dossier-export {
    justify-content: flex-start;
  }
}

@media (max-width: 820px) {
  .run-relation-document .relation-lead {
    padding-top: 36px;
  }

  .run-brochure-panel .brochure-layout,
  .workspace-form-grid {
    grid-template-columns: 1fr;
  }

  .workspace-quote-submit {
    align-items: stretch;
    flex-direction: column;
  }

  .workspace-quote-submit .button-primary {
    width: 100%;
  }

  .workspace-quote-brief-head {
    align-items: stretch;
    flex-direction: column;
  }

  .workspace-quote-brief-head > strong {
    width: fit-content;
  }

  .workspace-quote-brief dl > div {
    grid-template-columns: 1fr;
    gap: 5px;
  }
}

@media (max-width: 520px) {
  .run-workspace-focused .run-title .dossier-export {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .run-workspace-focused #outputDownload {
    grid-column: 1 / -1;
  }
}
