@charset "UTF-8";
/* =========================================================
   MetrIQ - Stylesheet
   Redesign "Precisione + Eleganza" — autorità visiva: DESIGN.md
   ========================================================= */

/* ----- Font self-hosted (nessun CDN a runtime) ----- */
@font-face { font-family: 'General Sans'; font-weight: 400; font-style: normal; font-display: swap; src: url('/static/fonts/general-sans-400.woff2') format('woff2'); }
@font-face { font-family: 'General Sans'; font-weight: 500; font-style: normal; font-display: swap; src: url('/static/fonts/general-sans-500.woff2') format('woff2'); }
@font-face { font-family: 'General Sans'; font-weight: 600; font-style: normal; font-display: swap; src: url('/static/fonts/general-sans-600.woff2') format('woff2'); }
@font-face { font-family: 'General Sans'; font-weight: 700; font-style: normal; font-display: swap; src: url('/static/fonts/general-sans-700.woff2') format('woff2'); }
@font-face { font-family: 'Zodiak'; font-weight: 400; font-style: normal; font-display: swap; src: url('/static/fonts/zodiak-400.woff2') format('woff2'); }
@font-face { font-family: 'Zodiak'; font-weight: 700; font-style: normal; font-display: swap; src: url('/static/fonts/zodiak-700.woff2') format('woff2'); }
@font-face { font-family: 'Spline Sans Mono'; font-weight: 400; font-style: normal; font-display: swap; src: url('/static/fonts/spline-sans-mono-400.woff2') format('woff2'); }
@font-face { font-family: 'Spline Sans Mono'; font-weight: 500; font-style: normal; font-display: swap; src: url('/static/fonts/spline-sans-mono-500.woff2') format('woff2'); }
/* Inter resta self-hosted SOLO per l'editor del computo (area bloccata, font pinnato) */
@font-face { font-family: 'Inter'; font-weight: 400; font-style: normal; font-display: swap; src: url('/static/fonts/inter-400.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-weight: 500; font-style: normal; font-display: swap; src: url('/static/fonts/inter-500.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-weight: 600; font-style: normal; font-display: swap; src: url('/static/fonts/inter-600.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-weight: 700; font-style: normal; font-display: swap; src: url('/static/fonts/inter-700.woff2') format('woff2'); }

/* ----- Reset & Base ----- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* MetrIQ palette: #1d3937 #195042 #91855a #d6cabc */
:root {
  --brand-deep:     #1d3937;
  --brand-emerald:  #195042;
  --brand-accent:   #91855a;
  --brand-sand:     #d6cabc;

  --color-bg:          #e8e1d4;
  --color-surface:     #faf7f1;
  --color-border:      rgba(29, 57, 55, 0.16);
  --color-text:        #1d3937;
  --color-text-muted:  #5a6862;
  --color-primary:     #195042;
  --color-primary-h:   #144238;
  --color-primary-soft: rgba(25, 80, 66, 0.14);
  --color-user-bg:     #195042;
  --color-user-text:   #faf7f1;
  --color-assist-bg:   #faf7f1;
  --color-assist-text: #1d3937;
  --color-header-bg:   #1d3937;
  --color-header-text: #f3eee4;
  --color-link:        #146b52;
  --color-divider:     rgba(29, 57, 55, 0.14);
  --color-loading-1:   #195042;
  --color-loading-2:   #6a9d8a;
  --color-focus-ring:  rgba(25, 80, 66, 0.35);

  --ce-toolbar-bg:      #195042;
  --ce-toolbar-fg:      #f3eee4;
  --ce-toolbar-border:  rgba(243, 238, 228, 0.2);
  --ce-editor-top:      #195042;
  --ce-table-hdr:       #1d3937;
  --ce-table-hdr-cell:  #142b28;
  --ce-tariffa:         #146b52;
  --ce-macro-row:       #e7dfcf;
  --ce-macro-text:      #1d3937;

  --shadow-sm:   0 1px 3px rgba(29, 57, 55, .06), 0 1px 2px rgba(29, 57, 55, .04);
  --shadow-md:   0 4px 14px rgba(29, 57, 55, .1), 0 2px 6px rgba(29, 57, 55, .06);
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --font-sans: 'General Sans', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-serif: 'Zodiak', Georgia, serif;
  --font-mono: 'Spline Sans Mono', 'Cascadia Code', 'Consolas', monospace;

  /* ---- Token v2 (DESIGN.md) ---- */
  --bg:        #e9e2d5;
  --surface:   #faf7f1;
  --raised:    #ffffff;
  --ink:       #1d3937;
  --ink-2:     #52625c;
  --ink-3:     #7d8a83;
  --hairline:  rgba(29, 57, 55, 0.14);
  --hairline-2:rgba(29, 57, 55, 0.08);
  --primary:   #195042;
  --primary-h: #143f34;
  --primary-ink: #f5f1e8;
  --gold-ink:  #7d7048;
  --accent-soft: #8ecfb8;
  --grid-line: rgba(29, 57, 55, 0.055);
  --focus:     rgba(25, 80, 66, 0.35);
  --shadow-1:  0 1px 2px rgba(29,57,55,.05), 0 4px 16px -8px rgba(29,57,55,.10);
  --shadow-2:  0 2px 4px rgba(29,57,55,.06), 0 16px 40px -16px rgba(29,57,55,.22);
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --r-sm: 9px;
  --r-md: 14px;
  --r-lg: 20px;
  --ctl-h: 44px;
  color-scheme: light;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --color-bg:          #101a19;
  --color-surface:     #172624;
  --color-border:      rgba(214, 202, 188, 0.18);
  --color-text:        #ede8df;
  --color-text-muted:  #b8c4bb;
  /* Primari: stesso smeraldo brand del chiaro, meno “neon” del mint */
  --color-primary:     #195042;
  --color-primary-h:   #236b56;
  --color-primary-soft: rgba(25, 80, 66, 0.38);
  --color-user-bg:     #195042;
  --color-user-text:   #f3eee4;
  --color-assist-bg:   #1c2826;
  --color-assist-text: #e8e2d6;
  --color-header-bg:   #0f2420;
  --color-header-text: #e8e2d6;
  --color-link:        #8ecfb8;
  --color-divider:     rgba(214, 202, 188, 0.12);
  --color-loading-1:   #3d8f76;
  --color-loading-2:   #2a5c4c;
  --color-focus-ring:  rgba(142, 207, 184, 0.5);
  /* Superfici annidate (pannello cronologia, card interne) */
  --color-surface-raised: #1c2e2a;

  --ce-toolbar-bg:      #0f2420;
  --ce-toolbar-fg:      #e8e2d6;
  --ce-toolbar-border:  rgba(232, 226, 214, 0.18);
  --ce-editor-top:      #195042;
  --ce-table-hdr:       #152d29;
  --ce-table-hdr-cell:  #0f211e;
  --ce-tariffa:         #7bc4aa;
  --ce-macro-row:       #233a35;
  --ce-macro-text:      #d6cabc;

  /* ---- Token v2 · tema scuro (DESIGN.md) ---- */
  --bg:        #0f1918;
  --surface:   #172523;
  --raised:    #1d2e2b;
  --ink:       #ece7dc;
  --ink-2:     #a8b5ad;
  --ink-3:     #76857d;
  --hairline:  rgba(214, 202, 188, 0.16);
  --hairline-2:rgba(214, 202, 188, 0.08);
  --primary:   #226753;
  --primary-h: #2b7d64;
  --primary-ink: #f0ece1;
  --gold-ink:  #c2b183;
  --grid-line: rgba(214, 202, 188, 0.05);
  --focus:     rgba(142, 207, 184, 0.45);
  --shadow-1:  0 1px 2px rgba(0,0,0,.2), 0 4px 16px -8px rgba(0,0,0,.35);
  --shadow-2:  0 2px 4px rgba(0,0,0,.25), 0 16px 40px -16px rgba(0,0,0,.5);
}

/* Griglia editor del computo: AREA BLOCCATA — font pinnati sui valori pre-redesign
   (le var sono ridefinite in scope, così ogni var() interno risolve i legacy).
   Toolbar e pannello assistente sono FUORI da questo scope: adottano i token v2. */
.ce-table-wrap,
.ce-change-nav {
  --font-sans: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-mono: 'Cascadia Code', 'Consolas', 'Courier New', monospace;
  font-family: var(--font-sans);
}

html, body {
  height: 100%;
  font-family: var(--font-sans);
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 15px;
  line-height: 1.6;
  overflow: hidden;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ----- Header ----- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--color-header-bg);
  border-bottom: 1px solid rgba(255,255,255,.08);
  box-shadow: var(--shadow-md);
}

.header-inner {
  width: 100%;
  padding: 10px max(20px, env(safe-area-inset-right, 0px)) 10px max(20px, env(safe-area-inset-left, 0px));
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: space-between;
}

.header-user-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
  max-width: min(100%, 420px);
}
.header-user-name {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--color-header-text);
  opacity: 0.92;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* Segnala che il nome è cliccabile e apre le impostazioni, non solo testo. */
.header-user-settings-icon {
  flex-shrink: 0;
  color: var(--color-header-text);
  opacity: 0.65;
  transition: opacity 0.15s;
}
.header-user-bar:hover .header-user-settings-icon,
.header-user-bar:focus-visible .header-user-settings-icon {
  opacity: 0.95;
}
.header-credits-badge {
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: .02em;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(22, 163, 74, 0.2);
  border: 1px solid rgba(22, 163, 74, 0.4);
  color: var(--color-header-text);
  font-variant-numeric: tabular-nums;
}

.header-theme-toggle {
  flex-shrink: 0;
  padding: 6px 12px;
  font-size: 12.5px;
  font-weight: 600;
  font-family: inherit;
  color: var(--color-header-text);
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.header-theme-toggle:hover {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.26);
}
.header-theme-toggle:focus-visible {
  outline: 2px solid var(--color-header-text);
  outline-offset: 2px;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--color-header-text);
  flex-shrink: 0;
}

.header-logo-link {
  text-decoration: none;
  border-radius: 8px;
  padding: 2px 4px;
  transition: background 0.15s ease;
}

.header-logo-link:hover {
  background: rgba(255, 255, 255, 0.08);
}

.header-logo-link:focus-visible {
  outline: 2px solid var(--color-header-text);
  outline-offset: 2px;
}

.header-title {
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 400;
  letter-spacing: -0.01em;
  color: var(--color-header-text);
}

/* Il logotipo MetrIQ — il lettering disegnato, non la parola composta con un
   font. Vive qui perche' lo usano tanto l'applicazione quanto la landing.
 *
 * PERCHE' UNA MASCHERA E NON UN <img>. Il logotipo deve prendere il colore di
 * cio' che lo circonda, come faceva il testo che sostituisce: sulla barra e'
 * crema, altrove potrebbe non esserlo, e nessuno deve ricordarsi di
 * mantenere allineate due copie di colore diverso. Un <img> ha i suoi colori
 * dentro e non li cambia; una maschera ritaglia currentColor, quindi segue.
 *
 * PERCHE' UN FILE ESTERNO E NON L'SVG IN LINEA. Il tracciato pesa 85 KB —
 * viene da una vettorializzazione, non da un disegno pulito — e ripeterlo
 * dentro cinque pagine significherebbe rispedirlo a ogni visita. Cosi' il
 * browser lo scarica una volta e lo tiene.
 *
 * La misura si da' in altezza: la larghezza segue da aspect-ratio, e nessuno
 * deve ricalcolare due numeri quando cambia idea. */
.logotipo-metriq {
  display: block;
  aspect-ratio: 481 / 144;
  background-color: currentColor;
  -webkit-mask: url('/static/assets/logotipo-metriq.svg') no-repeat center / contain;
          mask: url('/static/assets/logotipo-metriq.svg') no-repeat center / contain;
}

/* 26 e non 18. Allineare la maiuscola del logotipo a quella del testo che
   c'era prima darebbe 18px, ed e' la misura corretta se si vuole passare
   inosservati — ma qui il logotipo E' il marchio, non una parola nella frase,
   e a quella misura si legge timido. Scelta deliberata, non una svista.
   La barra non ha altezza fissa: cresce col contenuto, e i pulsanti accanto
   la tengono su comunque. */
.header-logo .logotipo-metriq { height: 26px; }

.header-back-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: transparent;
  color: var(--color-header-text);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.header-back-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.3);
}

.btn-new {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-header-text);
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.15);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background .15s, border-color .15s;
  white-space: nowrap;
  flex-shrink: 0;
}
.btn-new:hover {
  background: rgba(255,255,255,.18);
  border-color: rgba(255,255,255,.25);
}
.btn-new:active { transform: scale(.97); }

/* ----- App body: sidebar + chat ----- */
.app-body {
  display: flex;
  height: calc(100vh - 57px);
  overflow: hidden;
}

/* ----- Sidebar ----- */
.sidebar {
  width: 256px;
  background: #111827;
  border-right: 1px solid rgba(255,255,255,.07);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
}

.sidebar-top {
  padding: 12px;
  border-bottom: 1px solid rgba(255,255,255,.07);
  flex-shrink: 0;
}

.btn-new-chat {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 14px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 8px;
  color: #f1f5f9;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s;
}
.btn-new-chat:hover { background: rgba(255,255,255,.15); }
.btn-new-chat:active { transform: scale(.97); }

.sessions-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sessions-list::-webkit-scrollbar { width: 4px; }
.sessions-list::-webkit-scrollbar-track { background: transparent; }
.sessions-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 2px; }

.sessions-empty {
  text-align: center;
  font-size: 12.5px;
  color: rgba(241,245,249,.35);
  padding: 24px 10px;
}

.session-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 9px 11px;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background .12s;
  min-width: 0;
}
.session-item:hover { background: rgba(255,255,255,.07); }
.session-item.active {
  background: rgba(25, 80, 66, 0.28);
  border-color: rgba(25, 80, 66, 0.4);
}

.session-title {
  font-size: 12.5px;
  color: #cbd5e1;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
}
.session-item.active .session-title { color: #e2e8f0; }

.session-date {
  font-size: 11px;
  color: rgba(241,245,249,.38);
}

/* Sidebar toggle button (hidden on desktop) */
.btn-sidebar-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 6px;
  border: none;
  background: rgba(255,255,255,.1);
  color: var(--color-header-text);
  cursor: pointer;
  flex-shrink: 0;
  transition: background .15s;
}
.btn-sidebar-toggle:hover { background: rgba(255,255,255,.18); }

/* Overlay for mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 199;
  background: rgba(0,0,0,.45);
}

/* ----- Chat Wrapper ----- */
.chat-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

/* ----- Messages Container ----- */
.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 24px 20px 16px;
  scroll-behavior: smooth;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Scrollbar custom */
.messages-container::-webkit-scrollbar { width: 6px; }
.messages-container::-webkit-scrollbar-track { background: transparent; }
.messages-container::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: 3px; }

/* ----- Message Row ----- */
.message-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  max-width: 100%;
  animation: fadeSlide .22s ease forwards;
}

@keyframes fadeSlide {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.user-row {
  flex-direction: row-reverse;
}

/* ----- Avatars ----- */
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}

.user-avatar {
  background: var(--color-user-bg);
  color: #fff;
}

.assistant-avatar {
  background: var(--color-header-bg);
  color: #93c5fd;
}

/* ----- Bubbles ----- */
.bubble {
  max-width: 75%;
  padding: 12px 16px;
  border-radius: var(--radius-lg);
  line-height: 1.65;
  word-break: break-word;
  box-shadow: var(--shadow-sm);
}

.user-bubble {
  background: var(--color-user-bg);
  color: var(--color-user-text);
  border-top-right-radius: var(--radius-sm);
}

.assistant-bubble {
  background: var(--color-assist-bg);
  color: var(--color-assist-text);
  border-top-left-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
}

/* ----- Markdown dentro le bubble ----- */
.assistant-bubble strong { font-weight: 600; }
.assistant-bubble em { font-style: italic; }

.assistant-bubble .inline-code {
  font-family: var(--font-mono);
  font-size: 13px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  padding: 1px 5px;
  color: #0f172a;
}

.assistant-bubble .md-h4 {
  font-size: 14px;
  font-weight: 700;
  margin: 8px 0 4px;
  color: #0f172a;
  text-transform: uppercase;
  letter-spacing: .3px;
}

.assistant-bubble .md-list {
  margin: 6px 0 6px 6px;
  padding-left: 14px;
  list-style: none;
}
.assistant-bubble .md-list li {
  position: relative;
  padding-left: 14px;
  margin-bottom: 4px;
}
.assistant-bubble .md-list li::before {
  content: '\2013';
  position: absolute;
  left: 0;
  color: var(--color-primary);
  font-weight: 600;
}

.assistant-bubble .divider {
  border: none;
  border-top: 1px solid var(--color-divider);
  margin: 12px 0;
}

/* ----- Link pratiche ----- */
.practice-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--color-link);
  font-weight: 500;
  text-decoration: none;
  padding: 1px 6px;
  border-radius: 4px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  font-size: 13.5px;
  transition: background .12s, border-color .12s;
}
.practice-link:hover {
  background: #dbeafe;
  border-color: #93c5fd;
  text-decoration: none;
}
.practice-link::before {
  content: '\1F4C4';
  font-size: 11px;
}

/* ----- Session hint ----- */
.session-hint {
  text-align: center;
  font-size: 12px;
  color: var(--color-text-muted);
  padding: 4px;
  animation: fadeSlide .2s ease forwards;
}

/* ----- Loading Bar ----- */
.loading-bar {
  display: none;
  height: 3px;
  background: #e0e7ff;
  overflow: hidden;
  flex-shrink: 0;
}

.loading-bar-inner {
  height: 100%;
  background: linear-gradient(
    90deg,
    var(--color-loading-2) 0%,
    var(--color-loading-1) 40%,
    var(--color-loading-2) 100%
  );
  background-size: 200% 100%;
  animation: loadingSlide 1.4s ease-in-out infinite;
}

@keyframes loadingSlide {
  0%   { background-position: 200% center; }
  100% { background-position: -200% center; }
}

/* ----- Input Area ----- */
.input-area {
  padding: 12px 20px 16px;
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  flex-shrink: 0;
}

.input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: #f8fafc;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 8px 8px 8px 14px;
  transition: border-color .15s, box-shadow .15s;
}

.input-wrapper:focus-within {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-soft);
}

.user-textarea {
  flex: 1;
  border: none;
  background: transparent;
  resize: none;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  color: var(--color-text);
  min-height: 24px;
  max-height: 160px;
  outline: none;
}

.user-textarea::placeholder { color: var(--color-text-muted); }
.user-textarea:disabled { opacity: .6; }

.send-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: none;
  background: var(--color-primary);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .15s, transform .1s;
}
.send-btn:hover:not(:disabled) { background: var(--color-primary-h); }
.send-btn:active:not(:disabled) { transform: scale(.93); }
.send-btn:disabled {
  background: #cbd5e1;
  cursor: not-allowed;
}

.input-hint {
  font-size: 11.5px;
  color: var(--color-text-muted);
  margin-top: 6px;
  text-align: center;
}

/* ----- Responsive ----- */
@media (max-width: 768px) {
  /* Sidebar slide-in on mobile */
  .sidebar {
    position: fixed;
    top: 57px;
    left: 0;
    bottom: 0;
    z-index: 200;
    transform: translateX(-100%);
    transition: transform .25s ease;
  }
  body.sidebar-open .sidebar {
    transform: translateX(0);
  }
  body.sidebar-open .sidebar-overlay {
    display: block;
  }
  .btn-sidebar-toggle {
    display: flex;
  }
}

@media (max-width: 640px) {
  .header-subtitle { display: none; }
  .bubble { max-width: 90%; }
  .messages-container { padding: 16px 12px 12px; }
  .input-area { padding: 10px 12px 14px; }
}

/* ----- Bubble wrap (contenitore bubble + feedback) ----- */
.bubble-wrap {
  display: flex;
  flex-direction: column;
  max-width: 75%;
  gap: 0;
}

.user-row .bubble-wrap {
  align-items: flex-end;
}

.assistant-row .bubble-wrap {
  align-items: flex-start;
}

/* Override bubble max-width: ora e gestita dal wrap */
.bubble-wrap .bubble {
  max-width: 100%;
}

/* Avviso art. 50 AI Act: deve essere «chiaro e distinguibile», quindi non un
   grigetto da nota a pie' di pagina — ma nemmeno un allarme, perche' non
   segnala un pericolo. Filetto dorato a sinistra: si legge, non urla, e non
   compete con i messaggi della conversazione. */
.ai-avviso {
  margin: 0 0 10px;
  padding: 8px 12px;
  border-left: 2px solid var(--gold-ink, #91855a);
  background: color-mix(in srgb, var(--gold-ink, #91855a) 7%, transparent);
  border-radius: 0 var(--radius-sm, 6px) var(--radius-sm, 6px) 0;
  font-size: 12px;
  line-height: 1.5;
  /* Colore del testo normale, non quello attenuato: l'art. 50 chiede un avviso
     «chiaro e distinguibile», e un grigio da nota a pie' di pagina non lo e'.
     Il filetto dorato basta a distinguerlo dai messaggi senza gridare. */
  color: var(--color-text);
}

/* ----- Thinking bubble ----- */
.thinking-bubble {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  min-width: 200px;
  background: var(--color-assist-bg);
  color: var(--color-text-muted);
  font-size: 13.5px;
  font-style: italic;
}

.thinking-phase {
  transition: opacity .3s ease;
}

/* Tempo trascorso. Compare solo dopo qualche secondo (soglia in app.js):
   cronometrare un'attesa breve la fa sembrare piu' lunga di quanto sia.
   Tabulare perche' le cifre non ballino a ogni battito. */
.thinking-elapsed {
  margin-left: auto;
  padding-left: 12px;
  font-family: var(--font-mono, monospace);
  font-style: normal;
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  color: var(--color-text-muted);
  opacity: .75;
  white-space: nowrap;
}

/* La bolla vive dentro la chat della relazione, che impagina i messaggi con
   le proprie regole: qui si annulla solo cio' che confliggerebbe (larghezza
   da bolla utente, allineamento) lasciando intatto il resto. */
.computi-rel-msg.thinking-bubble {
  width: auto;
  align-self: flex-start;
  border-radius: var(--r-lg, 14px);
}

/* Tre puntini animati */
.thinking-dots {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.thinking-dots span {
  display: block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--primary);
  animation: thinking-bounce 1.2s ease-in-out infinite;
}
@media (prefers-reduced-motion: reduce) {
  .thinking-dots span { animation: none; opacity: .7; }
}

/* Sul tema scuro --primary (#226753) cade a 2.39:1 sul fondo della bolla:
   sotto la soglia di 3:1 per gli elementi non testuali, cioe' l'animazione
   che deve dire «sto lavorando» diventava quasi invisibile proprio dove
   serve. --accent-soft e' l'emerald che il tema scuro usa gia' altrove e
   sale a 9:1. */
:root[data-theme="dark"] .thinking-dots span {
  background: var(--accent-soft, #8ecfb8);
}

.thinking-dots span:nth-child(1) { animation-delay: 0s; }
.thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes thinking-bounce {
  0%, 60%, 100% { transform: translateY(0);    opacity: .5; }
  30%            { transform: translateY(-5px); opacity: 1; }
}

/* ----- Typing: fade-in per ogni riga nuova ----- */
@keyframes line-appear {
  from { opacity: 0; transform: translateY(3px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ----- Feedback bar ----- */
.feedback-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 2px;
  margin-top: 4px;
}

.feedback-label {
  font-size: 11.5px;
  color: var(--color-text-muted);
  margin-right: 2px;
}

.feedback-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid var(--color-border);
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
  flex-shrink: 0;
}

.feedback-good:hover {
  background: #dcfce7;
  border-color: #86efac;
  color: #16a34a;
}

.feedback-bad:hover {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #dc2626;
}

.feedback-done {
  font-size: 11.5px;
  padding: 3px 8px;
  border-radius: 4px;
  font-weight: 500;
}

.feedback-done--good {
  color: #16a34a;
  background: #dcfce7;
}

.feedback-done--bad {
  color: #2563eb;
  background: #eff6ff;
}

/* ----- Correction box ----- */
.correction-box {
  margin-top: 8px;
  background: var(--raised);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  padding: 12px 14px;
  animation: fadeSlide .18s ease forwards;
  width: 100%;
}

.correction-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 8px;
}

.correction-textarea {
  width: 100%;
  border: 1px solid var(--hairline);
  border-radius: var(--r-sm);
  padding: 8px 10px;
  font-family: var(--font-sans);
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--surface);
  resize: vertical;
  outline: none;
  transition: border-color .15s;
}

.correction-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--focus);
}

.correction-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

.correction-btn {
  padding: 6px 14px;
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background .12s, opacity .12s;
  border: 1px solid transparent;
}

.correction-cancel {
  background: transparent;
  border-color: var(--hairline);
  color: var(--ink-2);
}
.correction-cancel:hover { background: var(--surface); }

.correction-send {
  background: var(--primary);
  color: var(--primary-ink);
  border-color: var(--primary);
}
.correction-send:hover:not(:disabled) { background: var(--primary-h); }
.correction-send:disabled { opacity: .6; cursor: not-allowed; }

/* ----- Pulsante allegato ----- */
.attach-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--color-border);
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .12s, color .12s, border-color .12s;
}
.attach-btn:hover:not(:disabled) {
  background: #eff6ff;
  color: var(--color-primary);
  border-color: #bfdbfe;
}
.attach-btn--active {
  background: #eff6ff;
  color: var(--color-primary);
  border-color: var(--color-primary);
}
.attach-btn:disabled { opacity: .45; cursor: not-allowed; }

/* ----- Anteprima file allegato nell'input ----- */
.file-preview-row {
  display: flex;
  align-items: center;
  padding: 0 2px 8px;
}

.file-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 8px 6px 11px;
  background: var(--raised);
  border: 1px solid var(--hairline);
  border-radius: 999px;
  font-size: 12.5px;
  color: var(--color-text);
  font-weight: 500;
  max-width: 100%;
}
:root[data-theme="dark"] .file-chip { background: rgba(255,255,255,.03); }

.file-chip-icon { flex-shrink: 0; color: var(--ink-3); }

.file-chip-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 260px;
}

.file-chip-remove {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: none;
  background: var(--hairline-2);
  color: var(--ink-3);
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
  transition: background .12s, color .12s;
}
.file-chip-remove:hover { background: rgba(161,69,58,.15); color: #a1453a; }

/* Drag-over state sull'input wrapper */
.input-wrapper.drag-over {
  border-color: var(--color-primary);
  background: #eff6ff;
  box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}

/* ----- Bubble utente con file allegato ----- */
.file-bubble-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  background: rgba(255,255,255,.18);
  border: 1px solid rgba(255,255,255,.3);
  border-radius: 10px;
  font-size: 12.5px;
  font-weight: 500;
  margin-bottom: 6px;
  max-width: 100%;
}

.file-bubble-chip span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}

.file-bubble-text {
  font-size: 14.5px;
  line-height: 1.5;
  word-break: break-word;
}

/* ----- Barra "Aggiungi alla Knowledge Base" ----- */
.add-to-kb-bar {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
  padding: 10px 12px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: var(--radius-md);
  animation: fadeSlide .18s ease forwards;
}

.add-to-kb-label {
  font-size: 12px;
  color: #166534;
}

.add-to-kb-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  align-self: flex-start;
  padding: 6px 14px;
  background: #16a34a;
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background .12s, opacity .12s;
}
.add-to-kb-btn:hover:not(:disabled) { background: #15803d; }
.add-to-kb-btn:disabled { opacity: .6; cursor: not-allowed; }

.add-to-kb-done {
  font-size: 12.5px;
  color: #166534;
  font-weight: 600;
}

.add-to-kb-error {
  font-size: 12.5px;
  color: #dc2626;
}


/* =========================================================
   TAB NAVIGATION (header)
   ========================================================= */

.header-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  margin-right: 8px;
}

.header-tab {
  padding: 6px 16px;
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 20px;
  background: transparent;
  color: rgba(255,255,255,0.65);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
  white-space: nowrap;
}
.header-tab:hover {
  background: rgba(255,255,255,0.1);
  color: #fff;
}
.header-tab.active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}


/* =========================================================
   SEZIONI (chatbot / computi)
   ========================================================= */

.app-section {
  display: none;
  height: calc(100dvh - 57px);
  min-height: 0;
  overflow: hidden;
}
.app-section.active {
  display: flex;
  flex-direction: column;
}

/* La sezione chatbot mantiene il layout originale */
#section-chatbot.active {
  display: block;
}


/* =========================================================
   SEZIONE COMPUTI METRICI
   ========================================================= */

.computi-gate {
  flex: 1;
  min-height: 0; /* consente scroll nel flex parent (section) senza tagliare il contenuto */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
  background:
    radial-gradient(circle at 12% 8%, rgba(25, 80, 66, 0.14), transparent 45%),
    radial-gradient(circle at 88% 20%, rgba(145, 133, 90, 0.12), transparent 42%),
    linear-gradient(180deg, #e8e1d4 0%, #dcd3c4 100%);
}

:root[data-theme="dark"] .computi-gate {
  background:
    radial-gradient(circle at 12% 8%, rgba(90, 184, 154, 0.08), transparent 45%),
    radial-gradient(circle at 88% 20%, rgba(145, 133, 90, 0.06), transparent 42%),
    linear-gradient(180deg, #101a19 0%, #0c1413 100%);
}

/* Login / scelta / relazione: scrolling quando il contenuto supera il viewport */
#section-computi.computi-auth-flow .computi-gate {
  flex: 1;
  min-height: 0;
  align-items: flex-start;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

/* Schermata scelta workflow: torna a riempire l’area (override align sopra) */
#section-computi.computi-auth-flow .computi-gate.computi-gate--choice {
  align-items: stretch;
  justify-content: stretch;
}

/* Vista relazione: overlay fisso sotto l'header (nessuna sidebar in questa app) */
.computi-gate--coming {
  position: fixed !important;
  top: 57px;
  left: env(safe-area-inset-left, 0px);
  right: env(safe-area-inset-right, 0px);
  bottom: 0;
  padding: 16px;
  padding-bottom: max(16px, env(safe-area-inset-bottom, 0px));
  overflow: hidden !important;
  display: flex !important;
  align-items: stretch !important;
  justify-content: flex-start;
  flex-direction: column;
  z-index: 10;
  box-sizing: border-box;
}

/* iOS / Chrome Android: altezza rispetto alla viewport visibile (barra indirizzo) */
@supports (height: 100dvh) {
  .computi-gate--coming {
    height: calc(100dvh - 57px);
    min-height: calc(100dvh - 57px);
    bottom: auto;
  }
}

/* Unico figlio visibile: riempie l'overlay tramite altezza 100% esplicita */
.computi-gate--coming #computi-coming-view {
  display: flex !important;
  flex-direction: column;
  flex: none !important;
  height: 100% !important;
  width: 100%;
  min-width: 0;
  min-height: 0;
  max-height: none !important;
}

.computi-gate--choice {
  align-items: stretch;
  justify-content: stretch;
  padding: 0 !important;
}

.computi-gate--choice #computi-choice-view {
  width: 100%;
  max-width: none;
  height: 100%;
}

.computi-choice-layout {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  background: var(--bg);
  overflow: hidden;
}

/* Composizione centrata come nel mockup approvato: la planimetria resta a
   tutto schermo dietro (vedi .computi-choice-blueprint), solo cronologia +
   card restano contenute entro una larghezza massima ed equidistanti dai
   bordi su schermi larghi. */
.computi-choice-inner {
  position: relative; z-index: 1;
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 0;
  width: 100%;
  max-width: 1260px;
  height: 100%;
  margin: 0 auto;
}

@media (max-width: 768px) {
  .computi-choice-inner {
    flex-direction: column;
    height: auto;
    overflow-y: auto;
  }
}

/* Velo caldo dietro tutta la schermata */
.computi-choice-layout::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(55% 45% at 88% 8%, rgba(25, 80, 66, 0.07), transparent 70%),
    radial-gradient(50% 45% at 6% 96%, rgba(145, 133, 90, 0.09), transparent 70%);
}

/* Planimetria tecnica: firma visiva della schermata, si disegna come un plotter */
.computi-choice-blueprint {
  position: absolute; inset: 0; width: 100%; height: 100%;
  color: var(--ink); pointer-events: none; z-index: 0;
  mask-image: radial-gradient(45% 42% at 58% 30%, rgba(0,0,0,.25) 10%, rgba(0,0,0,.7) 52%, #000 82%);
  -webkit-mask-image: radial-gradient(45% 42% at 58% 30%, rgba(0,0,0,.25) 10%, rgba(0,0,0,.7) 52%, #000 82%);
}
:root[data-theme="dark"] .computi-choice-blueprint { color: var(--brand-sand); }
.computi-choice-blueprint .bp-main { opacity: 0.16; }
:root[data-theme="dark"] .computi-choice-blueprint .bp-main { opacity: 0.18; }
.computi-choice-blueprint .bp-gold { opacity: 0.55; color: var(--gold-ink); }
.computi-choice-blueprint text {
  font-family: var(--font-mono); font-size: 15px; letter-spacing: .22em;
  fill: currentColor; stroke: none; opacity: 0;
}
.computi-choice-blueprint .bp-quota { font-size: 12px; letter-spacing: .04em; }
.computi-choice-blueprint .bp-area { font-size: 13px; letter-spacing: .08em; }
.computi-choice-blueprint .dr { stroke-dasharray: 1; stroke-dashoffset: 1; }
@keyframes bp-draw { to { stroke-dashoffset: 0; } }
@keyframes bp-fade { to { opacity: 1; } }
.computi-choice-blueprint .bp-fill { opacity: 0; }
@keyframes bp-poche { to { opacity: 0.12; } }
:root[data-theme="dark"] .computi-choice-blueprint .bp-fill { }
@media (prefers-reduced-motion: no-preference) {
  .computi-choice-blueprint .bp-g1 .dr { animation: bp-draw 1.8s var(--ease) 0.2s forwards; }
  .computi-choice-blueprint .bp-g2 .dr { animation: bp-draw 1.6s var(--ease) 1.4s forwards; }
  .computi-choice-blueprint .bp-g3 .dr { animation: bp-draw 1.5s var(--ease) 2.6s forwards; }
  .computi-choice-blueprint .bp-g4 .dr { animation: bp-draw 1.2s var(--ease) 3.6s forwards; }
  .computi-choice-blueprint .bp-fill { animation: bp-poche 1.2s ease 1.6s forwards; }
  .computi-choice-blueprint text { animation: bp-fade 1s ease 4.2s forwards; }
}
@media (prefers-reduced-motion: reduce) {
  .computi-choice-blueprint .dr { stroke-dashoffset: 0; }
  .computi-choice-blueprint .bp-fill { opacity: 0.12; }
  .computi-choice-blueprint text { opacity: 1; }
}

.computi-choice-kicker {
  font-family: var(--font-mono); font-size: 11.5px; letter-spacing: .16em;
  text-transform: uppercase; color: var(--gold-ink); margin-bottom: 14px;
}

@media (max-width: 768px) {
  .computi-choice-layout {
    flex-direction: column;
  }
}

.computi-history-panel {
  position: relative; z-index: 1;
  width: 320px;
  flex-shrink: 0;
  align-self: flex-start;
  margin: clamp(28px, 5vh, 64px) 0 clamp(28px, 5vh, 64px) clamp(20px, 3vw, 40px);
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
  padding: 20px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: none;
}

@media (max-width: 768px) {
  .computi-history-panel {
    width: calc(100% - 40px);
    max-width: none;
    max-height: 280px;
    margin: 20px;
  }
}

.computi-history-heading {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: 19px;
  letter-spacing: -0.01em;
  color: var(--color-text);
  margin-bottom: 18px;
  text-transform: none;
}

.computi-history-hint {
  display: none;
}

.computi-history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  padding-right: 4px;
}

.computi-history-item {
  position: relative;
  display: block;
  border-radius: 0;
  border: none;
  border-top: 1px solid var(--hairline-2);
  background: transparent;
  overflow: visible;
  transition: background 0.18s var(--ease);
}
.computi-history-item:first-child { border-top: none; }

.computi-history-item:hover,
.computi-history-item:focus-within {
  background: var(--raised);
}
:root[data-theme="dark"] .computi-history-item:hover,
:root[data-theme="dark"] .computi-history-item:focus-within {
  background: rgba(255,255,255,.05);
}

.computi-history-item-main {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px;
  margin: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  text-align: left;
  font: inherit;
  min-width: 0;
}

.computi-history-item-icon {
  flex-shrink: 0; display: grid; place-items: center;
  width: 38px; height: 38px; border-radius: 10px;
  background: rgba(25,80,66,.08); color: var(--primary);
}
:root[data-theme="dark"] .computi-history-item-icon { background: rgba(142,207,184,.08); color: var(--accent-soft); }

.computi-history-item-body {
  flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px;
}

.computi-history-item-actions {
  position: absolute; right: 6px; top: 50%;
  display: flex; flex-direction: column; align-items: flex-end; gap: 3px;
  padding: 6px 4px 6px 12px; border-radius: 8px;
  background: linear-gradient(90deg, transparent, var(--raised) 26%);
  opacity: 0; transform: translateY(-50%) translateX(-6px);
  transition: opacity .2s var(--ease), transform .25s var(--ease);
  pointer-events: none;
}
:root[data-theme="dark"] .computi-history-item-actions {
  background: linear-gradient(90deg, transparent, #1c2e2a 26%);
}
.computi-history-item:hover .computi-history-item-actions,
.computi-history-item:focus-within .computi-history-item-actions {
  opacity: 1; transform: translateY(-50%) translateX(0); pointer-events: auto;
}
/* Le azioni comparivano SOPRA il titolo e lo rendevano illeggibile proprio
   quando lo stai scegliendo: al passaggio il titolo si stringe e lascia
   loro la colonna di destra. */
.computi-history-item:hover .computi-history-item-main,
.computi-history-item:focus-within .computi-history-item-main {
  padding-right: 108px;
}

.computi-history-item-resume-btn,
.computi-history-item-usebase {
  font-family: var(--font-sans); font-size: 12px; font-weight: 600; color: var(--primary);
  background: none; border: none; cursor: pointer; padding: 2px 4px; border-radius: 6px;
  white-space: nowrap;
}
:root[data-theme="dark"] .computi-history-item-resume-btn { color: var(--accent-soft); }
.computi-history-item-resume-btn:hover,
.computi-history-item-usebase:hover { text-decoration: underline; text-underline-offset: 3px; }
.computi-history-item-usebase {
  color: var(--gold-ink); font-weight: 500;
}

.ce-frombase-modal {
  position: fixed;
  inset: 0;
  z-index: 900;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.ce-frombase-modal__backdrop {
  position: absolute; inset: 0;
  background: rgba(16, 32, 29, 0.55);
  backdrop-filter: blur(3px);
}
.ce-frombase-modal__box {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-2);
  padding: 20px 24px 20px;
  width: min(500px, 100%);
  max-width: 90vw;
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: mq-rise .45s var(--ease) both;
}
.ce-frombase-modal__box h3 {
  font-family: var(--font-serif); font-weight: 400; font-size: 24px;
  letter-spacing: -0.01em; margin: 0 0 2px;
}
.ce-frombase-modal__hint {
  font-size: 13px; color: var(--color-text-muted); line-height: 1.6; margin: 0 0 8px; max-width: 62ch;
}
.ce-frombase-modal__btn {
  display: flex; align-items: center; gap: 12px; width: 100%;
  min-height: var(--ctl-h); padding: 8px 14px;
  font-family: var(--font-sans); font-size: 13.5px; font-weight: 500; color: var(--color-text);
  background: var(--raised); border: 1px solid var(--hairline); border-radius: var(--r-sm);
  cursor: pointer; text-align: left;
  transition: border-color .2s, background .2s, box-shadow .2s;
}
:root[data-theme="dark"] .ce-frombase-modal__btn { background: rgba(255,255,255,.03); }
.ce-frombase-modal__btn:hover { border-color: var(--ink-3); box-shadow: var(--shadow-1); }
.ce-frombase-modal__btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.ce-frombase-modal__btn .rb-icon { color: var(--ink-3); flex-shrink: 0; }
.ce-frombase-modal__btn .rb-body { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.ce-frombase-modal__btn .rb-sub { font-size: 11.5px; font-weight: 400; color: var(--ink-3); }
.ce-frombase-modal__btn .rb-chev { color: var(--ink-3); flex-shrink: 0; transition: transform .2s var(--ease); }
.ce-frombase-modal__btn:hover .rb-chev { transform: translateX(3px); }
.ce-frombase-modal__foot {
  display: flex; justify-content: flex-end;
  padding-top: 10px; margin-top: 6px; border-top: 1px solid var(--hairline-2);
}
.ce-frombase-modal__cancel {
  background: none;
  border: 1px solid var(--hairline);
  border-radius: var(--r-sm);
  min-height: 36px;
  padding: 0 14px;
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: 13px;
  cursor: pointer;
  transition: border-color .2s, background .2s;
}
.ce-frombase-modal__cancel:hover { border-color: var(--ink-3); background: var(--surface); }

.computi-history-badge {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: .1em;
  color: var(--gold-ink); border: 1px solid rgba(145,133,90,.35);
  padding: 2.5px 8px; border-radius: 999px; text-transform: uppercase; flex-shrink: 0;
  background: none;
}

.computi-history-item-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text);
  line-height: 1.3;
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}

.computi-history-item-meta {
  display: flex; align-items: center; gap: 10px;
}

.computi-history-item-date {
  font-family: var(--font-mono); font-variant-numeric: tabular-nums;
  font-size: 11.5px;
  color: var(--ink-3);
}

.computi-history-item-remove {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--ink-3);
  font-size: 15px;
  line-height: 1;
  padding: 5px 7px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.computi-history-item-remove:hover {
  background: rgba(161,69,58,.09);
  color: #a1453a;
}

.computi-history-empty {
  font-size: 13px;
  color: var(--color-text-muted);
  line-height: 1.45;
  margin-top: 8px;
}

.computi-history-view-all {
  margin-top: 12px;
  padding-top: 14px;
  border-top: 1px solid var(--hairline-2);
  width: 100%;
  background: none;
  border-left: none; border-right: none; border-bottom: none;
  font-family: var(--font-sans); font-size: 13px; font-weight: 500;
  color: var(--color-text-muted);
  text-align: left;
  cursor: pointer;
  transition: color 0.15s;
}

.computi-history-view-all:hover {
  color: var(--primary);
}
:root[data-theme="dark"] .computi-history-view-all:hover { color: var(--accent-soft); }

.computi-choice-main {
  position: relative; z-index: 1;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  min-width: 0;
  padding: clamp(28px, 5vh, 64px) clamp(20px, 3vw, 40px);
  background: transparent;
  overflow-y: auto;
}

.computi-choice-header {
  text-align: left;
  margin-bottom: 36px;
  max-width: 640px;
}

.computi-choice-header h2 {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: clamp(34px, 3.6vw, 50px);
  line-height: 1.08;
  letter-spacing: -0.015em;
  color: var(--color-text);
  margin-bottom: 10px;
  text-wrap: balance;
}

.computi-choice-header p {
  font-size: 15.5px;
  color: var(--color-text-muted);
  max-width: 52ch;
}

.computi-workflow-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  max-width: 920px;
  width: 100%;
}

@media (max-width: 900px) {
  .computi-workflow-cards {
    grid-template-columns: 1fr;
  }
}

/* Altezza tarata sul contenuto reale più lungo (card "Relazione", 3 righe
   di descrizione) cosi le due card restano identiche a riposo invece di
   sfondare lo slot ciascuna in modo diverso — misurato: 342px naturali. */
.wf-slot { position: relative; height: 350px; }

.computi-workflow-card {
  position: absolute; top: 0; left: 0; right: 0; min-height: 100%;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  padding: clamp(22px, 2.4vw, 32px);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  box-shadow: none;
  overflow: hidden;
  transition: border-color .3s var(--ease), transform .45s var(--ease), box-shadow .45s var(--ease);
  z-index: 1;
}

:root[data-theme="dark"] .computi-workflow-card {
  background: var(--surface);
}

.computi-workflow-card:hover,
.computi-workflow-card:focus-within {
  transform: translateY(-5px) scale(1.025);
  box-shadow: var(--shadow-2);
  border-color: rgba(145,133,90,.5);
  z-index: 2;
}
.computi-workflow-card::after {
  content: ""; position: absolute; left: 0; right: 100%; bottom: 0; height: 2px;
  background: var(--brand-accent); transition: right .4s var(--ease);
}
.computi-workflow-card:hover::after, .computi-workflow-card:focus-within::after { right: 0; }

.computi-workflow-icon {
  width: auto; height: auto;
  display: inline-flex; padding: 11px; border-radius: 12px;
  background: rgba(25,80,66,.09); color: var(--primary); margin-bottom: 4px;
  transition: transform .45s var(--ease);
}
:root[data-theme="dark"] .computi-workflow-icon { background: rgba(142,207,184,.09); color: var(--accent-soft); }
.computi-workflow-card:hover .computi-workflow-icon { transform: translateY(-2px); }

/* LA LINEA DI QUOTA — firma del marchio.
   Era una pastiglia bordata: un pezzo generico, che qualunque prodotto puo'
   avere. DESIGN.md dichiara invece come firma «planimetria quotata, l'oro
   come gesto della misura», ed e' la grammatica che la landing usa in tutta
   la seconda meta'. Adottandola qui, l'etichetta e' la stessa cosa nei due
   posti: chi arriva dal sito ritrova il segno che ha appena visto.
   La linea con le tacche di estremita' sta in tre gradienti su un solo
   pseudo-elemento, perche' uno pseudo-elemento non puo' averne di propri. */
.wf-badge {
  display: flex; align-items: center; gap: 12px;
  align-self: stretch;              /* la scheda e' una colonna con align-items: flex-start */
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .18em;
  text-transform: uppercase; color: var(--gold-ink);
  margin: 16px 0 0;
}
.wf-badge::after {
  content: "";
  flex: 1 1 auto; min-width: 24px; height: 7px;
  background:
    linear-gradient(var(--hairline), var(--hairline)) 0 3px / 100% 1px no-repeat,
    linear-gradient(var(--hairline), var(--hairline)) 0 0 / 1px 7px no-repeat,
    linear-gradient(var(--hairline), var(--hairline)) 100% 0 / 1px 7px no-repeat;
}

.computi-workflow-card h3 {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: 23px;
  letter-spacing: -0.01em;
  color: var(--color-text);
  margin: 8px 0 6px;
  text-wrap: balance;
}

.computi-workflow-card p {
  font-size: 13.5px;
  color: var(--color-text-muted);
  line-height: 1.6;
  margin-bottom: 0;
  flex: none;
  max-width: 58ch;
}

.wf-feats-wrap {
  display: grid; grid-template-rows: 0fr; width: 100%;
  transition: grid-template-rows .5s var(--ease);
}
.wf-feats-inner { overflow: hidden; }
.computi-workflow-card:hover .wf-feats-wrap,
.computi-workflow-card:focus-within .wf-feats-wrap { grid-template-rows: 1fr; }
.wf-feats {
  list-style: none; display: flex; flex-direction: column; gap: 8px;
  margin: 18px 0 0; padding-top: 16px; border-top: 1px solid var(--hairline-2);
  opacity: 0; transform: translateY(6px);
  transition: opacity .4s var(--ease) .08s, transform .45s var(--ease) .08s;
}
.computi-workflow-card:hover .wf-feats,
.computi-workflow-card:focus-within .wf-feats { opacity: 1; transform: translateY(0); }
.wf-feats li { display: flex; align-items: baseline; gap: 10px; font-size: 13px; color: var(--color-text-muted); }
.wf-feats li i {
  width: 5px; height: 5px; border-radius: 50%; background: var(--brand-accent);
  transform: translateY(-2px); flex-shrink: 0;
}
.wf-feats li b { color: var(--color-text); font-weight: 600; }

.computi-workflow-btn {
  width: auto;
  margin-top: 16px;
  padding: 0;
  background: none;
  color: var(--primary);
  border: none;
  border-radius: 0;
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px;
  transition: color 0.2s;
}
:root[data-theme="dark"] .computi-workflow-btn { color: var(--accent-soft); }

.computi-workflow-btn:hover {
  background: none;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.wf-btn-arrow { transition: transform .25s var(--ease); }
.computi-workflow-card:hover .wf-btn-arrow,
.computi-workflow-card:focus-within .wf-btn-arrow { transform: translateX(4px); }

.computi-choice-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.computi-choice-btn--resume {
  max-width: 260px;
  width: auto;
  min-height: 42px;
  align-self: flex-start;
  text-align: center;
}

.computi-choice-btn--resume:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.computi-choice-help {
  margin-top: 10px;
  margin-bottom: 14px;
  padding: 12px 13px;
  border-radius: 10px;
  border: 1px solid var(--color-border);
  background: rgba(214, 202, 188, 0.2);
}

.computi-choice-help h3 {
  margin: 0 0 5px;
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--brand-accent);
}

.computi-choice-help p {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
}

.computi-gate-card--flush {
  margin: 0;
}

.computi-coming-subtitle {
  font-size: 14px;
  font-weight: 600;
  color: var(--brand-accent);
  margin-bottom: 8px;
}

/* ---------------------------------------------------------------------------
   Login View — split screen 50/50 (schermo intero senza header app)
--------------------------------------------------------------------------- */
body.computi-login-screen .app-header {
  display: none;
}

body.computi-login-screen #section-computi.app-section.active,
body.computi-login-screen #section-computi.active {
  height: 100dvh;
  min-height: 100dvh;
  max-height: 100dvh;
}

body.computi-login-screen #section-computi.computi-auth-flow .computi-gate:not(.computi-gate--choice):not(.computi-gate--coming) {
  flex: 1 1 auto;
  min-height: 100dvh;
  max-height: 100dvh;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0;
  align-items: stretch;
  justify-content: stretch;
}

body.computi-login-screen .computi-login-layout {
  min-height: 100dvh;
  flex-direction: row;
  align-items: stretch;
  background: transparent;
}

@supports not (height: 1dvh) {
  body.computi-login-screen #section-computi.app-section.active,
  body.computi-login-screen #section-computi.active {
    height: 100vh;
    min-height: 100vh;
    max-height: 100vh;
  }
  body.computi-login-screen #section-computi.computi-auth-flow .computi-gate:not(.computi-gate--choice):not(.computi-gate--coming) {
    min-height: 100vh;
    max-height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
  }
  body.computi-login-screen .computi-login-layout {
    min-height: 100vh;
  }
}

.computi-login-layout {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  /* Sempre: sinistra = hero, destra = form (anche con dir=rtl sul documento) */
  direction: ltr;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  min-height: 100dvh;
  margin: 0;
  padding: 0;
  flex: 1 0 auto;
  position: relative;
  z-index: 1;
  background: var(--color-bg);
}

@supports not (height: 1dvh) {
  .computi-login-layout {
    min-height: 100vh;
  }
}

.computi-login-left {
  flex: 1 1 46%;
  order: 1;
  min-width: 0;
  min-height: inherit;
  position: relative;
  overflow: hidden;
  color: #f4f0e6;
  background-image:
    radial-gradient(ellipse 90% 70% at 50% 105%, rgba(10, 26, 22, 0.55) 0%, transparent 60%),
    linear-gradient(125deg, rgba(25, 80, 66, 0.82) 0%, rgba(17, 48, 41, 0.72) 55%, rgba(12, 35, 30, 0.86) 100%),
    url('/static/assets/login-bg.jpg');
  background-size: cover;
  background-position: center;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: clamp(32px, 5vw, 64px);
}

.computi-login-left-top { position: relative; }

.computi-login-brand-mark {
  display: inline-flex; align-items: center; gap: 12px;
  margin-bottom: clamp(40px, 9vh, 96px);
}
.computi-login-brand-mark svg { color: var(--brand-sand); }
.computi-login-brand-mark span {
  font-family: var(--font-mono); font-size: 12px; font-weight: 500;
  letter-spacing: .22em; text-transform: uppercase; color: var(--brand-sand);
}
/* Il colore si mette sul contenitore e non sul logotipo: la maschera ritaglia
   currentColor, quindi eredita da qui senza una regola in piu'. */
.computi-login-brand-mark { color: var(--brand-sand); }
/* Piu' grande che nella barra, e non per capriccio: qui il logotipo sta sopra
   una fotografia invece che su un fondo pieno, e sotto ha un titolo enorme.
   A 20px si perdeva fra le due cose. */
.computi-login-brand-mark .logotipo-metriq { height: 28px; }

.computi-login-brand-title {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: clamp(2.6rem, 4.8vw, 4.5rem);
  color: #ffffff;
  margin: 0 0 20px;
  letter-spacing: -0.015em;
  line-height: 1.06;
  max-width: 14ch;
  text-wrap: balance;
  text-shadow: 0 2px 24px rgba(10, 26, 22, 0.35);
}
.computi-login-brand-title em {
  font-style: normal;
  color: var(--brand-sand);
}

.computi-login-brand-subtitle {
  font-size: clamp(0.95rem, 1.3vw, 1.05rem);
  font-weight: 400;
  color: rgba(244, 240, 230, .82);
  line-height: 1.65;
  margin: 0;
  max-width: 42ch;
  text-shadow: 0 1px 12px rgba(10, 26, 22, 0.4);
}

.computi-login-brand-claim {
  position: relative;
  font-family: var(--font-serif); font-weight: 400;
  font-size: 15.5px;
  color: rgba(244, 240, 230, .6);
  margin: 0;
}
.computi-login-brand-claim b { color: var(--brand-sand); font-weight: 700; }

.computi-login-right {
  flex: 1 1 54%;
  order: 2;
  min-width: 0;
  min-height: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  background: var(--color-surface);
  padding: clamp(24px, 4vw, 56px);
}

.computi-login-theme-toggle {
  position: absolute;
  top: max(16px, env(safe-area-inset-top, 0px));
  right: max(20px, env(safe-area-inset-right, 0px));
  z-index: 2;
  padding: 8px 14px;
  font-size: 12.5px;
  font-weight: 600;
  font-family: inherit;
  color: var(--color-text-muted);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.computi-login-theme-toggle:hover {
  background: rgba(25, 80, 66, 0.06);
  border-color: rgba(25, 80, 66, 0.28);
  color: var(--color-text);
}

.computi-login-theme-toggle:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.computi-login-card {
  width: min(400px, 100%);
  background: transparent;
  border-radius: 0;
  box-shadow: none;
  padding: 0;
  border: none;
}

.computi-login-card h2 {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: 33px;
  letter-spacing: -0.01em;
  color: var(--color-text);
  margin-bottom: 6px;
  text-align: left;
}

.computi-login-hint {
  font-size: 14px;
  color: var(--color-text-muted);
  margin: 0;
}

.computi-login-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin-top: 30px;
}

.computi-login-field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.computi-login-field label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--color-text-muted);
  letter-spacing: .01em;
}

.computi-login-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.computi-login-icon {
  position: absolute;
  left: 13px;
  color: var(--color-text-muted);
  pointer-events: none;
}

.computi-login-input-wrap input {
  width: 100%;
  min-height: var(--ctl-h);
  padding: 10px 40px 10px 40px;
  border: 1px solid var(--hairline);
  border-radius: var(--r-sm);
  font-family: var(--font-sans);
  font-size: 14.5px;
  color: var(--color-text);
  background: var(--raised);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.computi-login-input-wrap input::placeholder { color: var(--color-text-muted); }
.computi-login-input-wrap input:hover { border-color: var(--ink-3); }

.computi-login-input-wrap input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--focus);
}

.computi-login-eye-btn {
  position: absolute;
  right: 6px;
  background: none;
  border: none;
  color: var(--ink-3);
  cursor: pointer;
  padding: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  transition: color .15s, background .15s;
}

.computi-login-eye-btn:hover {
  background: var(--hairline-2);
  color: var(--color-text);
}
.computi-login-eye-btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }

.computi-password-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  color: var(--color-text-muted);
  cursor: pointer;
}

.computi-password-toggle input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--color-primary);
  cursor: pointer;
}

.computi-login-btn {
  background: var(--primary);
  color: var(--primary-ink);
  border: none;
  border-radius: var(--r-sm);
  min-height: var(--ctl-h);
  padding: 0 14px;
  font-family: var(--font-sans);
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s var(--ease), transform .2s var(--ease), box-shadow .25s var(--ease);
  margin-top: 6px;
}

.computi-login-btn:hover {
  background: var(--primary-h);
  transform: translateY(-1px);
  box-shadow: var(--shadow-2);
}
.computi-login-btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.computi-google-btn:hover {
  border-color: var(--ink-3) !important;
  box-shadow: var(--shadow-1);
  transform: none;
}

.computi-login-help-links {
  margin-top: 26px !important;
}

.computi-login-help-links button,
.computi-login-help-links a {
  color: var(--color-text-muted);
  font-size: 13.5px;
  text-decoration: none;
  font-weight: 500;
  border-bottom: 1px solid transparent;
  transition: color .15s, border-color .15s;
}
#computi-toggle-auth-mode-btn { text-decoration: none !important; color: var(--color-text-muted) !important; }

.computi-login-help-links a:hover,
.computi-login-help-links button:hover {
  color: var(--gold-ink);
  border-bottom-color: var(--gold-ink);
  text-decoration: none;
}

.computi-login-legal-footer {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 14px;
  margin: 34px 0 0;
  padding-top: 18px;
  border-top: 1px solid var(--hairline-2);
  font-size: 12px;
  color: var(--ink-3);
}

.computi-login-legal-footer a {
  color: var(--ink-3);
  text-decoration: none;
}

.computi-login-legal-footer a:hover {
  color: var(--color-text-muted);
  text-decoration: underline;
}

/* Hide old auth flow styles */
#section-computi.computi-auth-flow .computi-gate {
  padding: 0;
  justify-content: flex-start;
}

@media (max-width: 640px) {
  body.computi-login-screen #section-computi.app-section.active,
  body.computi-login-screen #section-computi.active {
    height: auto;
    min-height: 100dvh;
    max-height: none;
  }
  body.computi-login-screen #section-computi.computi-auth-flow .computi-gate:not(.computi-gate--choice):not(.computi-gate--coming) {
    min-height: 100dvh;
    max-height: none;
    overflow-y: auto;
  }
  .computi-login-layout {
    flex-direction: column;
    min-height: calc(100dvh - 57px);
  }
  body.computi-login-screen .computi-login-layout {
    min-height: 100dvh;
  }
  .computi-login-left {
    flex: 0 0 auto;
    order: 1;
    min-height: 200px;
    max-height: 42vh;
    padding: 32px 20px;
  }
  .computi-login-right {
    flex: 1 1 auto;
    order: 2;
    min-height: 0;
    padding: 48px 20px 32px;
  }
  .computi-login-card {
    padding: 32px 24px;
    box-shadow: none;
    border: none;
  }
}

@media (max-width: 768px) {
}

/* Dark mode overrides for new login */
:root[data-theme="dark"] .computi-login-right {
  background: var(--color-bg);
}
:root[data-theme="dark"] .computi-login-card h2,
:root[data-theme="dark"] .computi-login-field label {
  color: var(--color-text);
}
:root[data-theme="dark"] .computi-login-input-wrap input {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--color-border);
  color: var(--color-text);
}
:root[data-theme="dark"] .computi-password-toggle {
  color: var(--color-text-muted);
}
:root[data-theme="dark"] .computi-login-help-links a,
:root[data-theme="dark"] .computi-login-help-links button {
  color: var(--color-text-muted);
}
:root[data-theme="dark"] .computi-login-help-links a:hover,
:root[data-theme="dark"] .computi-login-help-links button:hover {
  color: var(--gold-ink);
  border-bottom-color: var(--gold-ink);
}

:root[data-theme="dark"] .computi-login-theme-toggle {
  color: var(--color-text-muted);
  background: var(--color-surface-raised);
  border-color: var(--color-border);
}

:root[data-theme="dark"] .computi-login-theme-toggle:hover {
  background: rgba(90, 184, 154, 0.12);
  border-color: rgba(90, 184, 154, 0.35);
  color: var(--color-text);
}

.computi-login-error {
  color: #a1453a;
  background: rgba(161, 69, 58, 0.08);
  border: 1px solid rgba(161, 69, 58, 0.30);
  border-radius: var(--r-sm);
  padding: 8px 10px;
  font-size: 13px;
}

:root[data-theme="dark"] .computi-login-error {
  color: #fca5a5;
  background: rgba(127, 29, 29, 0.35);
  border-color: rgba(248, 113, 113, 0.45);
}

.computi-choice-btn {
  margin-top: 6px;
  border: 1px solid var(--hairline);
  border-radius: var(--r-sm);
  background: var(--raised);
  color: var(--ink);
  padding: 11px 14px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, border-color .15s;
  width: 100%;
  text-align: left;
}

.computi-choice-btn:hover {
  background: rgba(214, 202, 188, 0.45);
  border-color: rgba(25, 80, 66, 0.28);
}

/* Tema scuro: pulsanti secondari (es. “Relazione + computo”) — no sfondo chiaro */
:root[data-theme="dark"] .computi-choice-btn:not(.computi-choice-btn--primary) {
  background: rgba(255,255,255,.03);
  color: var(--ink);
  border-color: var(--hairline);
}

:root[data-theme="dark"] .computi-choice-btn:not(.computi-choice-btn--primary):hover {
  background: rgba(255,255,255,.06);
  border-color: rgba(214, 202, 188, 0.28);
}

:root[data-theme="dark"] .computi-choice-btn--primary:hover {
  background: var(--primary-h);
  border-color: var(--primary-h);
}

.computi-choice-actions {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.computi-choice-btn--primary {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-ink);
}

.computi-choice-btn--primary:hover {
  background: var(--primary-h);
  border-color: var(--primary-h);
}


:root[data-theme="dark"] .computi-choice-help {
  background: rgba(25, 80, 66, 0.25);
  border-color: rgba(214, 202, 188, 0.2);
}

#section-computi.computi-auth-flow .computi-login-btn,
#section-computi.computi-auth-flow .computi-choice-btn {
  appearance: none;
  -webkit-appearance: none;
}

#section-computi.computi-auth-flow .computi-gate-card {
  border-color: var(--color-border);
}

#section-computi.computi-auth-flow .computi-gate-card h2 {
  font-size: 24px;
  letter-spacing: -0.2px;
}

#section-computi.computi-auth-flow .computi-login-brand {
  margin-bottom: 14px;
  border-color: rgba(25, 80, 66, 0.2);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

#section-computi.computi-auth-flow .computi-login-brand-title {
  font-size: clamp(2.6rem, 4.8vw, 4.5rem);
}

#section-computi.computi-auth-flow .computi-gate-card p {
  font-size: 14px;
}

#section-computi.computi-auth-flow .computi-choice-main.computi-gate-card {
  max-width: none;
  padding: 26px 24px;
  border-radius: 16px;
  border: 1px solid var(--color-border);
  background: linear-gradient(180deg, var(--color-surface) 0%, rgba(214, 202, 188, 0.18) 100%);
  box-shadow:
    var(--shadow-md),
    inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

#section-computi.computi-auth-flow .computi-choice-main .computi-choice-btn {
  min-height: 54px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 700;
  padding: 12px 16px;
  transition: transform .14s ease, box-shadow .16s ease, background .16s ease, border-color .16s ease;
}

#section-computi.computi-auth-flow .computi-choice-main .computi-choice-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(25, 80, 66, 0.14);
}

#section-computi.computi-auth-flow .computi-choice-main .computi-choice-btn:focus-visible {
  outline: 3px solid var(--color-focus-ring);
  outline-offset: 2px;
}

#section-computi.computi-auth-flow .computi-history-hint,
#section-computi.computi-auth-flow .computi-history-empty {
  font-size: 13px;
}

:root[data-theme="dark"] .computi-history-item {
  background: var(--color-surface-raised);
}

:root[data-theme="dark"] .computi-history-item:hover {
  border-color: rgba(142, 207, 184, 0.35);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
}

:root[data-theme="dark"] .computi-history-badge {
  background: rgba(214, 202, 188, 0.14);
  color: var(--brand-sand);
}

:root[data-theme="dark"] .computi-history-badge--relazione {
  background: rgba(145, 133, 90, 0.4);
  color: #f8f3e8;
}

:root[data-theme="dark"] .computi-history-badge--solo_computo {
  background: rgba(25, 80, 66, 0.5);
  color: #d4ebe2;
}

:root[data-theme="dark"] .computi-history-item-remove:hover {
  background: rgba(220, 38, 38, 0.15);
}

:root[data-theme="dark"] #section-computi.computi-auth-flow .computi-choice-main.computi-gate-card {
  background: linear-gradient(180deg, var(--color-surface) 0%, var(--color-surface-raised) 100%);
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.4);
  border-color: var(--color-border);
}

:root[data-theme="dark"] #section-computi.computi-auth-flow .computi-login-brand {
  box-shadow: none;
  border-color: var(--color-border);
}

:root[data-theme="dark"] #section-computi.computi-auth-flow .computi-choice-main .computi-choice-btn:not(.computi-choice-btn--primary):hover {
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
}

:root[data-theme="dark"] #section-computi.computi-auth-flow .computi-choice-main .computi-choice-btn--primary:hover {
  box-shadow: 0 8px 20px rgba(25, 80, 66, 0.35);
}

#computi-app-shell {
  height: 100%;
  min-height: 0;
}

.computi-wrapper {
  display: grid;
  grid-template-columns: 360px 10px 1fr;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  transition: grid-template-columns .22s ease;
}

.computi-wrapper.computi-wrapper--left-collapsed {
  grid-template-columns: 0 10px 1fr;
}

.computi-wrapper.computi-wrapper--left-collapsed .computi-config-panel {
  opacity: 0;
  pointer-events: none;
}

/* --- Divisore cliccabile tra pannello sinistro e destro --- */
.computi-panel-divider {
  grid-column: 2;
  grid-row: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 10px;
  height: 100%;
  background: var(--color-border);
  border: none;
  padding: 0;
  cursor: pointer;
  position: relative;
  z-index: 10;
  transition: background .15s;
  -webkit-tap-highlight-color: transparent;
}

.computi-panel-divider:hover,
.computi-panel-divider:focus-visible {
  background: var(--color-primary);
  outline: none;
}

.computi-panel-divider-arrow {
  display: block;
  width: 16px;
  height: 32px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 1px 4px rgba(0,0,0,0.12);
  pointer-events: none;
}

.computi-panel-divider-arrow::after {
  content: '';
  display: block;
  width: 6px;
  height: 6px;
  border-right: 2px solid var(--color-text-muted);
  border-bottom: 2px solid var(--color-text-muted);
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-65%, -50%) rotate(-45deg);
  transition: transform .2s ease;
}

.computi-wrapper--left-collapsed .computi-panel-divider-arrow::after {
  transform: translate(-35%, -50%) rotate(135deg);
}

@media (max-width: 1024px) {
  .computi-panel-divider {
    display: none;
  }
}

@media (max-width: 768px) {
  .computi-wrapper {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    overflow-y: auto;
  }
}

/* --- Pannello configurazione (sinistra) --- */
.computi-config-panel {
  background: var(--surface);
  border-right: 1px solid var(--hairline);
  padding: 22px 22px 0;
  overflow-x: hidden;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
  transition: opacity .2s ease;
}
.computi-send-footer {
  position: sticky; bottom: 0;
  z-index: 2;
  margin: 4px -22px 0;
  padding: 16px 22px 20px;
  background: linear-gradient(to top, var(--surface) 72%, transparent);
  flex-shrink: 0;
}

.computi-nav-row {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
}

.computi-back-btn {
  display: inline-flex;
  width: auto;
  align-items: center;
  gap: 7px;
  border: none;
  border-radius: 7px;
  background: none;
  color: var(--color-text-muted);
  padding: 4px 8px;
  margin-left: -8px;
  margin-top: 0;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, color .15s;
}

.computi-back-btn:hover {
  background: var(--hairline-2);
  color: var(--color-text);
}

.computi-left-toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--r-sm);
  border: 1px solid var(--hairline);
  background: var(--raised);
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background .14s, border-color .14s;
  flex-shrink: 0;
}

.computi-left-toggle-btn:hover {
  background: rgba(25, 80, 66, 0.08);
  border-color: rgba(25, 80, 66, 0.35);
}

.computi-left-expand-btn {
  display: none;
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 100;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: var(--r-sm);
  border: 1px solid var(--hairline);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  transition: background .14s, border-color .14s;
  box-shadow: var(--shadow-1);
}

.computi-left-expand-btn:hover {
  background: var(--color-surface-hover, rgba(25, 80, 66, 0.08));
  border-color: rgba(25, 80, 66, 0.35);
}

/* Nella toolbar dell'editor il pulsante assume i colori della toolbar */
.computi-result-panel--editor-active .computi-left-expand-btn {
  top: 8px;
  left: 8px;
  border-color: rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.12);
  color: var(--ce-toolbar-fg);
  box-shadow: none;
}

.computi-result-panel--editor-active .computi-left-expand-btn:hover {
  background: rgba(255, 255, 255, 0.22);
  border-color: rgba(255, 255, 255, 0.4);
}

.computi-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: 27px;
  letter-spacing: -0.01em;
  color: var(--color-text);
}
.computi-title svg { color: var(--gold-ink); flex-shrink: 0; }

.computi-desc {
  font-size: 13.5px;
  color: var(--color-text-muted);
  line-height: 1.6;
  max-width: 44ch;
}

/* Mode toggle: segmented control */
.computi-mode-toggle {
  display: flex;
  flex-shrink: 0;
  gap: 4px;
  background: var(--bg);
  border: 1px solid var(--hairline);
  border-radius: 11px;
  padding: 4px;
  min-height: var(--ctl-h);
}
.mode-btn {
  flex: 1;
  padding: 0 12px;
  border: none;
  border-radius: 8px;
  background: transparent;
  font-family: var(--font-sans);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink-2);
  cursor: pointer;
  transition: background .2s var(--ease), color .2s, box-shadow .2s;
}
.mode-btn.active {
  background: var(--raised);
  color: var(--color-text);
  box-shadow: var(--shadow-1);
}
:root[data-theme="dark"] .mode-btn.active {
  background: var(--primary);
  color: var(--primary-ink);
  box-shadow: none;
}
.mode-btn:hover:not(.active) {
  color: var(--color-text);
}
.mode-btn:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }

/* Card “Apri progetto” */
.computi-project-card {
  padding: 0;
  border: none;
  border-radius: 0;
  background: none;
  gap: 8px;
}
.computi-project-hint {
  margin: 0;
  font-size: 12px;
  color: var(--ink-3);
  line-height: 1.5;
}
.computi-project-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
  min-height: var(--ctl-h);
  margin-top: 2px;
  padding: 0 16px;
  border: 1px solid var(--hairline);
  border-radius: var(--r-sm);
  background: var(--raised);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, border-color .15s, box-shadow .15s;
}
:root[data-theme="dark"] .computi-project-btn { background: rgba(255,255,255,.03); }
.computi-project-btn:hover {
  border-color: var(--ink-3);
  box-shadow: var(--shadow-1);
}
.computi-project-btn svg { flex-shrink: 0; color: var(--ink-3); }

/* Fields */
.computi-field {
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.computi-label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: .16em;
}

/* Dropzone */
.computi-dropzone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 22px 16px;
  border: 1.5px dashed var(--hairline);
  border-radius: var(--r-md);
  background: var(--raised);
  cursor: pointer;
  text-align: center;
  transition: border-color .25s var(--ease), background .25s var(--ease);
}
:root[data-theme="dark"] .computi-dropzone { background: rgba(255,255,255,.03); }
.computi-dropzone:hover,
.computi-dropzone.dragover {
  border-color: var(--brand-accent);
  background: var(--surface);
}
:root[data-theme="dark"] .computi-dropzone:hover,
:root[data-theme="dark"] .computi-dropzone.dragover {
  background: rgba(255,255,255,.05);
}
.computi-dropzone svg { transition: color .25s, transform .3s var(--ease); }
.computi-dropzone:hover svg { color: var(--gold-ink); transform: translateY(-2px); }
.dropzone-text {
  font-size: 14px;
  font-weight: 500;
  color: var(--color-text);
}
.dropzone-link {
  color: var(--primary);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: var(--brand-accent);
  text-underline-offset: 3px;
}
:root[data-theme="dark"] .dropzone-link { color: var(--accent-soft); }
.dropzone-hint {
  font-size: 12px;
  color: var(--ink-3);
  opacity: 1;
}

/* File list */
.computi-file-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 4px;
}

/* Textarea note */
.computi-textarea {
  padding: 10px 13px;
  border: 1px solid var(--hairline);
  border-radius: var(--r-sm);
  font-family: var(--font-sans);
  font-size: 13.5px;
  line-height: 1.55;
  resize: vertical;
  min-height: 72px;
  background: var(--raised);
  color: var(--color-text);
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
:root[data-theme="dark"] .computi-textarea { background: rgba(255,255,255,.04); }
.computi-textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--focus); }
.computi-textarea::placeholder { color: var(--ink-3); }

.computi-select {
  min-height: var(--ctl-h);
  padding: 0 32px 0 13px;
  border: 1px solid var(--hairline);
  border-radius: var(--r-sm);
  font-family: var(--font-sans);
  font-size: 13.5px;
  background: var(--raised);
  color: var(--color-text);
  outline: none;
  cursor: pointer;
  transition: border-color .2s, box-shadow .2s;
  width: 100%;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%237d8a83' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}
:root[data-theme="dark"] .computi-select { background-color: rgba(255,255,255,.04); }
.computi-select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--focus); }

/* Send button */
.computi-send-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: var(--ctl-h);
  width: 100%;
  padding: 0 20px;
  background: var(--primary);
  color: var(--primary-ink);
  border: none;
  border-radius: var(--r-sm);
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: background .2s var(--ease), transform .2s var(--ease), box-shadow .25s var(--ease), opacity .13s;
}
.computi-send-btn:hover:not(:disabled) {
  background: var(--primary-h);
  transform: translateY(-1px);
  box-shadow: var(--shadow-2);
}
.computi-send-btn:disabled {
  opacity: .6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
  border: 1px solid var(--hairline);
}
.computi-send-btn.is-busy { cursor: wait; }
.computi-send-btn.is-busy #computi-send-icon { display: none; }
.computi-send-spinner {
  display: none;
  width: 15px; height: 15px; flex-shrink: 0;
  border: 2px solid rgba(240,236,225,.35);
  border-top-color: var(--primary-ink);
  border-radius: 50%;
  animation: ce-btn-spin .7s linear infinite;
}
.computi-send-btn.is-busy .computi-send-spinner { display: inline-block; }
@keyframes ce-btn-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .computi-send-spinner { animation: none; border-top-color: rgba(240,236,225,.35); }
}
.computi-send-btn::after {
  content: ""; position: absolute; top: 0; bottom: 0; left: -60%; width: 40%;
  background: linear-gradient(100deg, transparent, rgba(240,236,225,.14), transparent);
  transform: translateX(0) skewX(-18deg); transition: transform .6s var(--ease);
  pointer-events: none;
}
.computi-send-btn:hover:not(:disabled)::after { transform: translateX(450%) skewX(-18deg); }


/* --- Pannello risultati (destra) --- */
.computi-result-panel {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px),
    linear-gradient(rgba(145,133,90,.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(145,133,90,.07) 1px, transparent 1px);
  background-size: 8px 8px, 8px 8px, 40px 40px, 40px 40px;
  overflow: hidden;
  min-height: 0;
  position: relative;
}
/* Spazio in fondo allo scroll quando l'assistente computo è aperto (pannello fixed) */
.computi-result-panel.computi-result-panel--ce-agent-open {
  padding-bottom: 0;
}

.computi-result-panel.computi-result-panel--editor-active {
  overflow: hidden;
}

.computi-empty {
  position: relative; z-index: 1;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--color-text-muted);
  font-size: 14.5px;
  padding: 32px;
  text-align: center;
  max-width: 380px;
  margin: 0 auto;
}
.computi-empty p:first-of-type {
  font-family: var(--font-serif); font-weight: 400; font-size: 22px;
  color: var(--color-text); margin-bottom: 2px;
}
.computi-empty-sub { font-size: 13.5px; color: var(--ink-3); line-height: 1.6; }

/* Foglio stilizzato: motivo carta millimetrata + righe voce */
.re-sheet {
  width: 180px; height: 122px; margin: 0 auto 24px; position: relative;
  background: var(--surface); border: 1px solid var(--hairline); border-radius: 10px;
  box-shadow: var(--shadow-1); overflow: hidden;
}
.re-sheet::before {
  content: ""; position: absolute; inset: 0;
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 9px 9px;
}
.re-sheet i { position: absolute; left: 13px; right: 13px; height: 5px; border-radius: 3px; background: var(--hairline); }
.re-sheet i:nth-child(1) { top: 17px; width: 45%; background: rgba(145,133,90,.45); }
.re-sheet i:nth-child(2) { top: 34px; }
.re-sheet i:nth-child(3) { top: 49px; width: 72%; }
.re-sheet i:nth-child(4) { top: 64px; width: 84%; }
.re-sheet i:nth-child(5) { top: 87px; width: 38%; background: rgba(25,80,66,.35); }

.computi-loading {
  position: relative; z-index: 1;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--color-text-muted);
  font-size: 14.5px;
  padding: 32px;
  text-align: center;
  max-width: 380px;
  margin: 0 auto;
}
.computi-loading p:first-of-type {
  font-family: var(--font-serif); font-weight: 400; font-size: 22px;
  color: var(--color-text); margin-bottom: 2px;
}
.rl-track {
  height: 3px; border-radius: 2px; background: var(--hairline);
  overflow: hidden; margin: 0 auto 22px; width: 220px;
}
.rl-bar {
  height: 100%; width: 40%; border-radius: 2px;
  background: linear-gradient(90deg, var(--primary), var(--brand-accent));
  animation: mq-scan 1.6s var(--ease) infinite;
}
@keyframes mq-scan {
  0% { transform: translateX(-110%); }
  100% { transform: translateX(360%); }
}

.computi-result-content {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}
.computi-result-header {
  position: relative; z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 20px;
  border-bottom: 1px solid var(--hairline);
  background: var(--surface);
  flex-shrink: 0;
}
.result-badge {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .04em;
  padding: 4px 10px;
  border-radius: 999px;
}
.result-badge--ok    { background: rgba(25,80,66,.12); color: var(--primary); }
:root[data-theme="dark"] .result-badge--ok { background: rgba(142,207,184,.14); color: var(--accent-soft); }
.result-badge--error { background: rgba(161,69,58,.12); color: #a1453a; }

.computi-result-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.computi-copy-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 13px;
  border: 1px solid var(--hairline);
  border-radius: var(--r-sm);
  background: var(--raised);
  font-family: var(--font-sans);
  font-size: 12.5px;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}
.computi-copy-btn:hover { border-color: var(--ink-3); box-shadow: var(--shadow-1); }

/* Bottone Scarica Excel */
.computi-excel-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  padding: 0 14px;
  border: none;
  border-radius: var(--r-sm);
  background: var(--primary);
  color: var(--primary-ink);
  font-family: var(--font-sans);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s var(--ease), transform .2s var(--ease);
}
.computi-excel-btn:hover:not(:disabled) { background: var(--primary-h); transform: translateY(-1px); }
.computi-excel-btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.computi-result-body {
  position: relative; z-index: 1;
  padding: 24px;
  font-size: 14px;
  line-height: 1.7;
}

/* ===========================================================================
   COMPUTO EDITOR - Viewer/Editor interattivo stile MetriQ
   =========================================================================== */

.computo-editor-section {
  border-top: 2px solid var(--ce-editor-top);
  background: var(--color-surface);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 0;
  grid-template-rows: auto minmax(0, 1fr) auto;
  flex-shrink: 0;
  position: relative;
  min-height: 0;
  height: 100%;
}

.computo-editor-section.computo-editor-section--agent-open {
  grid-template-columns: minmax(0, 1fr) minmax(320px, var(--ce-agent-width, 420px));
}

/* Toolbar */
.ce-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  background: var(--ce-toolbar-bg);
  color: var(--ce-toolbar-fg);
  flex-shrink: 0;
  gap: 12px;
  flex-wrap: wrap;
  grid-column: 1 / -1;
  position: sticky;
  top: 0;
  z-index: 8;
}

.ce-toolbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ce-toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ce-toolbar-voice-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(243, 238, 228, 0.35);
  background: rgba(255, 255, 255, 0.12);
  color: var(--ce-toolbar-fg);
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.ce-toolbar-voice-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(243, 238, 228, 0.5);
}
.ce-toolbar-voice-btn:focus-visible {
  outline: 2px solid rgba(243, 238, 228, 0.85);
  outline-offset: 2px;
}
.ce-toolbar-voice-btn.ce-toolbar-voice-btn--active {
  background: rgba(142, 207, 184, 0.35);
  border-color: rgba(142, 207, 184, 0.65);
  box-shadow: 0 0 0 1px rgba(142, 207, 184, 0.4);
}

.ce-toolbar-title {
  font-family: var(--font-serif);
  font-size: 15.5px;
  font-weight: 400;
  letter-spacing: -0.005em;
}

.ce-toolbar-hint {
  font-size: 11.5px;
  opacity: .75;
}

.ce-project-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 14px;
  border: 1px solid rgba(243, 238, 228, 0.35);
  border-radius: var(--r-sm);
  background: rgba(255, 255, 255, 0.12);
  color: var(--ce-toolbar-fg);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background .13s, border-color .13s, opacity .13s;
  white-space: nowrap;
}
.ce-project-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(243, 238, 228, 0.5);
}
.ce-project-btn:disabled { opacity: .5; cursor: not-allowed; }

.ce-cloud-toolbar {
  display: none;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.ce-cloud-save-btn,
.ce-cloud-list-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border: 1px solid rgba(243, 238, 228, 0.35);
  border-radius: var(--r-sm);
  background: rgba(255, 255, 255, 0.12);
  color: var(--ce-toolbar-fg);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background .13s, border-color .13s, opacity .13s;
  white-space: nowrap;
}
.ce-cloud-list-btn {
  background: rgba(214, 202, 188, 0.16);
}
.ce-cloud-save-btn:hover:not(:disabled),
.ce-cloud-list-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(243, 238, 228, 0.5);
}
.ce-cloud-save-btn:disabled,
.ce-cloud-list-btn:disabled { opacity: .45; cursor: not-allowed; }

.ce-cloud-modal {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.ce-cloud-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(16, 32, 29, 0.55);
  backdrop-filter: blur(3px);
}
.ce-cloud-modal__panel {
  position: relative;
  z-index: 1;
  width: min(440px, 100%);
  max-height: min(72vh, 520px);
  overflow: auto;
  background: var(--surface);
  color: var(--color-text);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-2);
  padding: 20px 24px 20px;
  animation: mq-rise .45s var(--ease) both;
}
.ce-cloud-modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}
.ce-cloud-modal__head h3 {
  margin: 0;
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: 24px;
  letter-spacing: -0.01em;
}
.ce-cloud-modal__close {
  border: none;
  background: transparent;
  font-size: 1.4rem;
  line-height: 1;
  padding: 6px 9px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--ink-3);
  opacity: 1;
  transition: color .15s, background .15s;
}
.ce-cloud-modal__close:hover { color: var(--color-text); background: var(--hairline-2); }
.ce-cloud-modal__empty {
  margin: 8px 0 12px;
  font-size: 13px;
  opacity: .85;
}
.ce-cloud-modal__list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.ce-cloud-modal__item {
  border: 1px solid var(--hairline);
  border-radius: var(--r-sm);
  padding: 11px 13px;
  margin-bottom: 8px;
  font-size: 13px;
  transition: border-color .15s, background .15s;
}
.ce-cloud-modal__item:hover { border-color: var(--ink-3); background: var(--raised); }
.ce-cloud-modal__item-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  align-items: baseline;
  margin-bottom: 8px;
}
.ce-cloud-modal__item-title { font-weight: 600; color: var(--color-text); }
.ce-cloud-modal__item-meta { font-family: var(--font-mono); font-size: 11.5px; color: var(--ink-3); opacity: 1; }
.ce-cloud-modal__item-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.ce-cloud-modal__item-actions button {
  min-height: 32px;
  padding: 0 13px;
  border-radius: var(--r-sm);
  border: 1px solid var(--hairline);
  background: var(--raised);
  color: var(--color-text);
  font-family: var(--font-sans);
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 600;
  transition: border-color .15s, box-shadow .15s;
}
.ce-cloud-modal__item-actions button:hover { border-color: var(--ink-3); box-shadow: var(--shadow-1); }
.ce-cloud-open-btn { color: var(--primary); }
:root[data-theme="dark"] .ce-cloud-open-btn { color: var(--accent-soft); }
.ce-cloud-del-btn { color: #a1453a; }

:root[data-theme="dark"] .ce-cloud-modal__panel {
  background: var(--surface);
  color: var(--color-text);
}
:root[data-theme="dark"] .ce-cloud-modal__item {
  border-color: var(--hairline);
}
:root[data-theme="dark"] .ce-cloud-modal__item:hover { background: rgba(255,255,255,.03); }

/* Anteprima export PDF computo (modale + iframe) */
.ce-pdf-preview-modal {
  position: fixed;
  inset: 0;
  z-index: 1250;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 12px;
  box-sizing: border-box;
}
.ce-pdf-preview-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(16, 32, 29, 0.55);
  backdrop-filter: blur(3px);
}
.ce-pdf-preview-modal__panel {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: min(960px, 100%);
  max-height: min(92vh, 900px);
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-2);
  border: 1px solid var(--hairline);
  overflow: hidden;
  animation: mq-rise .4s var(--ease) both;
}
.ce-pdf-preview-modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--hairline);
  flex-shrink: 0;
}
.ce-pdf-preview-modal__head h3 {
  margin: 0;
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: 1.2rem;
}
.ce-pdf-preview-modal__close {
  border: none;
  background: transparent;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  color: var(--ink-3);
  padding: 2px 6px;
  border-radius: var(--r-sm);
}
.ce-pdf-preview-modal__close:hover {
  color: var(--ink);
  background: var(--hairline-2);
}
.ce-pdf-preview-modal__fallback {
  margin: 0;
  padding: 10px 16px;
  font-size: 13px;
  background: rgba(145, 133, 90, 0.12);
  color: var(--gold-ink);
  border-bottom: 1px solid rgba(145, 133, 90, 0.30);
}
.ce-pdf-preview-modal__frame-wrap {
  flex: 1;
  min-height: min(68vh, 640px);
  background: var(--raised);
}
.ce-pdf-preview-modal__iframe {
  display: block;
  width: 100%;
  height: 100%;
  min-height: min(68vh, 640px);
  border: none;
  /* pagina PDF: resta "carta" chiara in entrambi i temi */
  background: #fff;
}
.ce-pdf-preview-modal__actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px 18px 18px;
  border-top: 1px solid var(--hairline);
  flex-shrink: 0;
}
.ce-pdf-preview-modal__btn {
  padding: 0 20px;
  min-height: var(--ctl-h);
  border-radius: var(--r-sm);
  font-family: var(--font-sans);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background .2s var(--ease), transform .2s var(--ease), box-shadow .25s var(--ease);
}
.ce-pdf-preview-modal__btn--ghost {
  background: transparent;
  border-color: var(--hairline);
  color: var(--ink);
}
.ce-pdf-preview-modal__btn--ghost:hover {
  border-color: var(--ink-3);
  background: var(--raised);
}
.ce-pdf-preview-modal__btn--primary {
  background: var(--primary);
  color: var(--primary-ink);
  border-color: var(--primary);
}
.ce-pdf-preview-modal__btn--primary:hover {
  background: var(--primary-h);
  transform: translateY(-1px);
  box-shadow: var(--shadow-2);
}

.ce-excel-preview-modal {
  position: fixed;
  inset: 0;
  z-index: 1250;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 12px;
  box-sizing: border-box;
}
.ce-excel-preview-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(16, 32, 29, 0.55);
  backdrop-filter: blur(3px);
}
.ce-excel-preview-modal__panel {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: min(1120px, 100%);
  max-height: min(92vh, 920px);
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-2);
  border: 1px solid var(--hairline);
  overflow: hidden;
  animation: mq-rise .4s var(--ease) both;
}
.ce-excel-preview-modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--hairline);
}
.ce-excel-preview-modal__head h3 {
  margin: 0;
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: 1.2rem;
}
.ce-excel-preview-modal__close {
  border: none;
  background: transparent;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  color: var(--ink-3);
  padding: 2px 6px;
  border-radius: var(--r-sm);
}
.ce-excel-preview-modal__close:hover {
  color: var(--ink);
  background: var(--hairline-2);
}
.ce-excel-preview-modal__meta {
  margin: 0;
  padding: 10px 18px;
  font-size: 13px;
  color: var(--ink-2);
  border-bottom: 1px solid var(--hairline);
}
.ce-excel-preview-modal__table-wrap {
  flex: 1;
  overflow: auto;
  background: var(--raised);
}
.ce-excel-preview-modal__table {
  width: 100%;
  border-collapse: collapse;
  min-width: 980px;
  font-family: var(--font-sans);
}
.ce-excel-preview-modal__table th,
.ce-excel-preview-modal__table td {
  border: 1px solid var(--hairline);
  padding: 6px 8px;
  font-size: 12.5px;
  vertical-align: top;
  color: var(--ink);
}
.ce-excel-preview-modal__table th {
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
  text-align: center;
  font-family: var(--font-mono);
  font-weight: 500;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: .06em;
  font-size: 10.5px;
}
.ce-excel-preview-modal__table td:nth-child(1),
.ce-excel-preview-modal__table td:nth-child(4),
.ce-excel-preview-modal__table td:nth-child(5),
.ce-excel-preview-modal__table td:nth-child(6),
.ce-excel-preview-modal__table td:nth-child(7),
.ce-excel-preview-modal__table td:nth-child(8),
.ce-excel-preview-modal__table td:nth-child(9),
.ce-excel-preview-modal__table td:nth-child(10) {
  text-align: right;
  white-space: nowrap;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.ce-excel-preview-modal__table td:nth-child(3) {
  white-space: normal;
  min-width: 340px;
}
.ce-excel-preview-row--macro td {
  font-weight: 700;
  background: rgba(145, 133, 90, 0.12);
}
.ce-excel-preview-row--label td {
  background: var(--surface);
}
.ce-excel-preview-row--summary td {
  border-top: 1px solid var(--ink-3);
  background: var(--surface);
}
.ce-excel-preview-row--total td {
  font-weight: 700;
  background: rgba(25, 80, 66, 0.10);
}
.ce-excel-preview-modal__actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px 18px 18px;
  border-top: 1px solid var(--hairline);
}
.ce-excel-preview-modal__btn {
  padding: 0 20px;
  min-height: var(--ctl-h);
  border-radius: var(--r-sm);
  font-family: var(--font-sans);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background .2s var(--ease), transform .2s var(--ease), box-shadow .25s var(--ease);
}
.ce-excel-preview-modal__btn--ghost {
  background: transparent;
  border-color: var(--hairline);
  color: var(--ink);
}
.ce-excel-preview-modal__btn--ghost:hover {
  border-color: var(--ink-3);
  background: var(--raised);
}
.ce-excel-preview-modal__btn--primary {
  background: var(--primary);
  color: var(--primary-ink);
  border-color: var(--primary);
}
.ce-excel-preview-modal__btn--primary:hover {
  background: var(--primary-h);
  transform: translateY(-1px);
  box-shadow: var(--shadow-2);
}
.ce-excel-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 14px;
  border: 1px solid rgba(29, 57, 55, 0.18);
  border-radius: var(--r-sm);
  background: var(--brand-accent);
  color: #1d3937;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background .13s, opacity .13s;
  white-space: nowrap;
}
.ce-excel-btn:hover:not(:disabled) { background: #a4966a; }
.ce-excel-btn:disabled { opacity: .5; cursor: not-allowed; }
.ce-export-menu-wrap {
  position: relative;
}
.ce-export-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 165px;
  border: 1px solid var(--hairline);
  background: var(--surface);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-2);
  display: none;
  flex-direction: column;
  z-index: 30;
  padding: 6px;
}
.ce-export-menu.ce-export-menu--open {
  display: flex;
}
.ce-export-menu-item {
  border: none;
  background: transparent;
  color: var(--color-text);
  text-align: left;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  cursor: pointer;
}
.ce-export-menu-item:hover:not(:disabled) {
  background: var(--color-primary-soft);
  color: var(--color-primary);
}
.ce-export-menu-item:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* Wrapper tabella: scroll solo orizzontale, altezza libera */
.ce-table-wrap {
  overflow-x: auto;
  overflow-y: auto;
  height: 100%;
  min-height: 0;
  grid-column: 1;
  grid-row: 2;
}

/* Navigatore modifiche agente (tipo ricerca multipla) */
.ce-change-nav {
  grid-column: 1;
  grid-row: 3;
  display: none;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  padding: 8px 12px;
  padding-bottom: max(8px, env(safe-area-inset-bottom, 0px));
  background: linear-gradient(180deg, rgba(25, 80, 66, 0.12) 0%, rgba(25, 80, 66, 0.06) 100%);
  border-top: 1px solid var(--color-border);
  z-index: 15;
  box-sizing: border-box;
}

.ce-change-nav:not([hidden]) {
  display: flex;
}

.ce-change-nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  min-height: 40px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}

.ce-change-nav-btn:hover:not(:disabled) {
  background: var(--color-primary-soft);
  border-color: var(--color-primary);
}

.ce-change-nav-btn:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

.ce-change-nav-status {
  font-size: 13px;
  font-weight: 700;
  color: var(--color-text);
  font-variant-numeric: tabular-nums;
}

.ce-change-nav-voce {
  font-size: 12.5px;
  color: var(--color-text-muted);
  max-width: min(200px, 40vw);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ce-change-nav-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  min-height: 40px;
  margin-left: 4px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--color-text-muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  font-family: inherit;
}

.ce-change-nav-close:hover {
  background: var(--color-bg);
  color: var(--color-text);
}

.ce-table tbody tr.ce-change-flash td {
  animation: ceChangeFlashBg 15s ease-out forwards;
}

@keyframes ceChangeFlashBg {
  0% {
    background-color: rgba(34, 197, 94, 0.28);
  }
  100% {
    background-color: transparent;
  }
}

:root[data-theme="dark"] .ce-table tbody tr.ce-change-flash td {
  animation-name: ceChangeFlashBgDark;
}

@keyframes ceChangeFlashBgDark {
  0% {
    background-color: rgba(74, 222, 128, 0.22);
  }
  100% {
    background-color: transparent;
  }
}

.ce-scroll {
  min-width: 900px;
  min-height: 100%;
}

/* Messaggi di stato nel viewer */
.ce-parsing-msg {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 32px 24px;
  color: var(--ink-2);
  font-size: 14px;
  font-family: var(--font-sans);
  text-align: center;
}

.ce-parsing-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--hairline);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: ce-btn-spin .8s linear infinite;
  flex-shrink: 0;
}
@media (prefers-reduced-motion: reduce) {
  .ce-parsing-spinner { animation: none; border-top-color: var(--hairline); }
}

.ce-error {
  padding: 20px 24px;
  color: #a1453a;
  font-size: 13.5px;
  line-height: 1.6;
}

/* Progresso multi-agente (generazione computo "crea").
   Vive dentro .ce-table-wrap (finché la tabella vera non è pronta), che pinna
   font legacy per l'editor del computo: qui sovrascriviamo lo scope ai token v2,
   perché questo pannello non è la griglia dati protetta. */
.ce-ma-progress {
  --font-sans: 'General Sans', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-mono: 'Spline Sans Mono', 'Cascadia Code', 'Consolas', monospace;
  flex-direction: column;
  align-items: stretch;
  gap: 14px;
  padding: 28px 26px;
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
}
.ce-ma-head {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.ce-ma-status {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 14.5px;
  color: var(--ink);
  transition: opacity .2s var(--ease);
}
.ce-ma-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  text-align: left; /* la testata sopra è centrata, ma l'elenco resta una lista */
}
.ce-ma-row {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 8px 11px;
  border-radius: var(--r-sm);
  border: 1px solid var(--hairline);
  background: var(--raised);
  font-family: var(--font-sans);
  font-size: 12.5px;
  color: var(--ink-2);
  transition: background .3s var(--ease), border-color .3s var(--ease), color .3s var(--ease);
}
.ce-ma-row-top {
  display: flex;
  align-items: center;
  gap: 9px;
}
.ce-ma-row[data-state="ready"] {
  background: rgba(145,133,90,.10);
  border-color: rgba(145,133,90,.35);
  color: var(--gold-ink);
}
.ce-ma-row[data-state="done-ok"] {
  background: rgba(25,80,66,.08);
  border-color: rgba(25,80,66,.28);
  color: var(--ink);
}
.ce-ma-row[data-state="done-warn"] {
  background: rgba(161,69,58,.08);
  border-color: rgba(161,69,58,.30);
  color: var(--ink);
}
.ce-ma-row-dot {
  flex-shrink: 0;
  font-size: 9px;
  line-height: 1;
  color: var(--ink-3);
}
.ce-ma-row[data-state="pending"] .ce-ma-row-dot { animation: ce-ma-dot-pulse 1.2s ease-in-out infinite; }
.ce-ma-row[data-state="ready"] .ce-ma-row-dot { color: var(--gold-ink); }
.ce-ma-row[data-state="done-ok"] .ce-ma-row-dot { color: var(--primary); }
.ce-ma-row[data-state="done-warn"] .ce-ma-row-dot { color: #a1453a; }
@keyframes ce-ma-dot-pulse {
  0%, 100% { opacity: .35; }
  50%      { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .ce-ma-row[data-state="pending"] .ce-ma-row-dot { animation: none; opacity: .7; }
}
.ce-ma-row-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ce-ma-row-meta {
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}
.ce-ma-row-bar {
  height: 3px;
  border-radius: 2px;
  background: var(--hairline);
  overflow: hidden;
}
.ce-ma-row-bar-fill {
  height: 100%;
  width: 40%;
  border-radius: 2px;
  background: linear-gradient(90deg, transparent, var(--brand-accent), transparent);
  animation: mq-scan 1.4s var(--ease) infinite;
}
.ce-ma-row[data-state="done-ok"] .ce-ma-row-bar-fill {
  width: 100%;
  background: var(--primary);
  animation: none;
}
.ce-ma-row[data-state="done-warn"] .ce-ma-row-bar-fill {
  width: 100%;
  background: #a1453a;
  animation: none;
}
@media (prefers-reduced-motion: reduce) {
  .ce-ma-row-bar-fill { animation: none; }
}

/* ==== La tabella ==== */

.ce-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  font-family: 'Courier New', Courier, monospace;
  table-layout: fixed;
}

/* Intestazione */
.ce-hdr-row {
  background: var(--ce-table-hdr);
  color: var(--ce-toolbar-fg);
  position: sticky;
  top: 0;
  z-index: 4;
}

.ce-th {
  padding: 7px 6px;
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .4px;
  white-space: nowrap;
  border: 1px solid var(--ce-table-hdr-cell);
}

/* Larghezze colonne */
.ce-th-nr      { width: 64px; }  /* a 52 «Nr. Ord.» sconfinava in TARIFFA */
.ce-th-tariffa { width: 90px; }
.ce-th-desc    { width: auto; min-width: 260px; text-align: left; }
.ce-th-num     { width: 68px; }
/* «unitario €» e «TOTALE €» (penultima e terzultima, prima di .ce-th-act):
   a 68px con nowrap sconfinavano l'una nell'altra — «unitario €TOTALE €». */
.ce-th-num:nth-last-child(2),
.ce-th-num:nth-last-child(3) { width: 86px; }
.ce-th-act     { width: 36px; }

/* Celle generiche */
.ce-td {
  padding: 3px 5px;
  border: 1px solid #d1d5db;
  vertical-align: top;
  overflow-wrap: break-word;
  word-break: break-word;
}

/* Celle editabili - focus */
[contenteditable] {
  outline: none;
  cursor: text;
}
[contenteditable]:hover {
  background: var(--color-primary-soft);
}
[contenteditable]:focus {
  background: rgba(214, 202, 188, 0.35);
  box-shadow: inset 0 0 0 2px var(--color-primary);
  position: relative;
  z-index: 1;
}

:root[data-theme="dark"] [contenteditable]:focus {
  background: rgba(90, 184, 154, 0.12);
}

/* Celle numeriche */
.ce-td-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Celle calcolate (non direttamente editabili) */
.ce-td-computed {
  background: #f3f4f6;
  color: #374151;
  cursor: default;
}

/* Riga descrizione voce */
.ce-row-desc {
  background: #fff;
}

/* Highlight righe modificate dall'agente */
.ce-row-desc td {
  transition: background-color 1.4s ease;
}
.ce-row--modified td {
  background-color: #fef08a !important;
  transition: none;
}
:root[data-theme="dark"] .ce-row--modified td {
  background-color: #854d0e !important;
}

.ce-row-macro {
  background: var(--ce-macro-row);
}
.ce-td-macro {
  padding: 4px 8px;
  border-top: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
}
.ce-macro-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: none;
  background: transparent;
  color: var(--ce-macro-text);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .25px;
  cursor: pointer;
  padding: 2px 4px;
}
.ce-macro-arrow {
  display: inline-block;
  transition: transform .14s ease;
}
.ce-macro-arrow.collapsed {
  transform: rotate(-90deg);
}
.ce-macro-total {
  font-weight: 800;
  color: var(--ce-macro-text);
}

/* Quality flag indicators */
.ce-quality-dot {
  display: inline-block;
  font-size: 0.65em;
  vertical-align: middle;
  margin-left: 4px;
  cursor: help;
  line-height: 1;
}
.ce-quality-low  { color: #e8a800; }
.ce-quality-warn { color: #e05c00; }
.ce-quality-err  { color: #d0021b; }

/* Row border-left accent for non-OK voci */
.ce-row-desc[data-quality="low_score"] td:first-child {
  border-left: 3px solid #e8a800;
}
.ce-row-desc[data-quality="um_mismatch"] td:first-child {
  border-left: 3px solid #e05c00;
}
.ce-row-desc[data-quality="not_found"] td:first-child {
  border-left: 3px solid #d0021b;
}

/* Badge voci da verificare nel macro header */
.ce-quality-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  margin-left: 8px;
  background: #d0021b;
  color: #fff;
  border-radius: 9px;
  font-size: 0.72em;
  font-weight: 700;
  line-height: 1;
  cursor: help;
  vertical-align: middle;
}

.ce-td-nr {
  text-align: center;
  font-weight: 700;
  color: var(--ce-table-hdr);
}
.ce-td-nr--auto {
  cursor: default;
  user-select: none;
}

.ce-td-tariffa {
  font-weight: 600;
  color: var(--ce-tariffa);
  text-align: center;
}

.ce-td-desc {
  text-align: left;
  font-weight: 600;
  line-height: 1.5;
}

/* Intestazione MISURAZIONI */
.ce-row-mis-hdr {
  background: #e5e7eb;
}
.ce-mis-label {
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 1.5px;
  color: #374151;
  padding: 3px 8px;
}

/* Righe di misura */
.ce-row-mis {
  background: #f9fafb;
}
.ce-td-nota {
  font-style: italic;
  color: #374151;
  text-align: left;
}

/* Righe etichetta zona/ambiente (es. "Prospetto Nord", "Bagno 1") */
.ce-row-mis-label {
  background: rgba(214, 202, 188, 0.4);
}
.ce-td-label-text {
  font-weight: 700;
  font-size: 11px;
  color: var(--ce-table-hdr);
  padding: 3px 10px 3px 14px;
  border-left: 3px solid var(--brand-emerald) !important;
  letter-spacing: .3px;
  text-transform: uppercase;
}
.ce-td-label-text:hover { background: rgba(25, 80, 66, 0.12); }
.ce-td-label-text:focus {
  background: rgba(25, 80, 66, 0.18);
  box-shadow: inset 0 0 0 2px var(--brand-emerald);
}

/* Riga + aggiungi misura */
.ce-row-add-mis td {
  padding: 3px 8px;
  background: #f9fafb;
  border: 1px dashed #d1d5db;
}

.ce-btn-add-mis {
  background: none;
  border: 1px dashed #9ca3af;
  border-radius: 4px;
  color: #6b7280;
  font-size: 11px;
  padding: 2px 10px;
  cursor: pointer;
  transition: all .12s;
  margin-right: 6px;
}
.ce-btn-add-mis:hover {
  background: var(--color-primary-soft);
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.ce-btn-add-label {
  background: none;
  border: 1px dashed var(--brand-accent);
  border-radius: 4px;
  color: var(--brand-accent);
  font-size: 11px;
  padding: 2px 10px;
  cursor: pointer;
  transition: all .12s;
}
.ce-btn-add-label:hover {
  background: rgba(145, 133, 90, 0.18);
  border-style: solid;
  color: var(--color-text);
}

/* SOMMANO */
.ce-row-sommano {
  background: #d1fae5;
}
.ce-sommano-um {
  font-weight: 700;
  font-size: 11.5px;
  letter-spacing: .5px;
  color: #065f46;
  text-align: left;
}
.ce-td-importo {
  font-weight: 700;
  color: #065f46;
}

/* Separatore */
.ce-row-sep td {
  height: 6px;
  background: #f1f5f9;
  border: none;
}

/* TOTALE */
.ce-row-totale {
  background: var(--ce-table-hdr);
  color: var(--ce-toolbar-fg);
  position: sticky;
  bottom: 0;
}
.ce-totale-label {
  padding: 8px 10px;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: .5px;
  text-align: right;
  border: 1px solid var(--ce-table-hdr-cell);
}
.ce-totale-val {
  padding: 8px 8px;
  font-weight: 800;
  font-size: 14px;
  text-align: right;
  border: 1px solid var(--ce-table-hdr-cell);
  font-variant-numeric: tabular-nums;
}

/* Pulsante elimina riga/voce */
.ce-td-act {
  text-align: center;
  vertical-align: middle;
}
.ce-btn-del {
  background: none;
  border: none;
  color: #9ca3af;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 3px;
  transition: all .12s;
}
.ce-btn-del:hover {
  background: #fee2e2;
  color: #dc2626;
}

/* Pulsante aggiungi voce */
.ce-add-voce-wrap {
  padding: 12px 18px;
  border-top: 1px dashed #d1d5db;
  background: #f9fafb;
  position: sticky;
  bottom: 0;
  z-index: 3;
}
.ce-btn-add-voce {
  background: #eff6ff;
  border: 1px dashed #2563eb;
  border-radius: 6px;
  color: #1d4ed8;
  font-size: 12.5px;
  font-weight: 600;
  padding: 6px 18px;
  cursor: pointer;
  transition: all .13s;
}
.ce-btn-add-voce:hover {
  background: rgba(25, 80, 66, 0.2);
  border-style: solid;
}

/* ----- Toolbar: Annulla e Salva ----- */
.ce-undo-btn,
.ce-save-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border-radius: var(--r-sm);
  border: 1px solid rgba(255, 255, 255, .35);
  background: rgba(255, 255, 255, .14);
  color: var(--ce-toolbar-fg);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s, opacity 0.15s;
}
.ce-macro-bulk-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: var(--r-sm);
  border: 1px solid rgba(255, 255, 255, .35);
  background: rgba(255, 255, 255, .14);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}
.ce-macro-bulk-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, .24);
  border-color: rgba(255, 255, 255, .55);
}
.ce-macro-bulk-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.ce-undo-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, .24);
  border-color: rgba(255, 255, 255, .55);
}
.ce-undo-btn:disabled,
.ce-save-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.ce-save-btn {
  background: rgba(142, 207, 184, .22);
  border-color: rgba(142, 207, 184, .55);
  color: var(--ce-toolbar-fg);
}
.ce-save-btn:hover:not(:disabled) {
  background: rgba(142, 207, 184, .34);
  border-color: rgba(142, 207, 184, .75);
}
.ce-save-btn--saved {
  background: var(--brand-accent) !important;
  border-color: var(--brand-accent) !important;
  color: #1d3937 !important;
}

/* ----- Agente computo: FAB fixed (non copre la tabella) + pannello sotto ----- */
.ce-agent-fab {
  display: none;
  position: absolute;
  bottom: 18px;
  right: 18px;
  z-index: 9;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #195042 0%, #2d6b55 55%, #91855a 100%);
  color: #fff;
  box-shadow: 0 4px 16px rgba(25, 80, 66, 0.4);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, box-shadow 0.2s, opacity 0.2s;
}
.ce-agent-fab.ce-agent-fab--visible {
  display: flex;
}
.ce-agent-fab.ce-agent-fab--panel-open {
  opacity: 0;
  pointer-events: none;
}
.ce-agent-fab:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 22px rgba(25, 80, 66, 0.45);
}
.ce-agent-fab svg {
  flex-shrink: 0;
}
.ce-agent-fab-label {
  display: none;
}

.ce-agent-panel {
  position: relative;
  width: 100%;
  height: 100%;
  max-height: none;
  min-height: 0;
  overflow: hidden;
  z-index: 5;
  background: var(--color-surface);
  border-left: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transform: translateX(100%);
  pointer-events: none;
  transition: transform 0.24s ease-out;
  box-shadow: -4px 0 14px rgba(15, 23, 42, 0.08);
  grid-column: 2;
  grid-row: 2;
}
.ce-agent-panel.ce-agent-panel--open {
  transform: translateX(0);
  pointer-events: auto;
  border-left: 1px solid var(--color-primary);
}

.ce-agent-resize-handle {
  position: absolute;
  left: 0;
  top: 0;
  width: 6px;
  height: 100%;
  cursor: col-resize;
  background: transparent;
  z-index: 3;
}

.ce-agent-resize-handle:hover {
  background: var(--color-primary-soft);
}
.ce-agent-panel-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--color-border);
  background: rgba(214, 202, 188, 0.2);
}

:root[data-theme="dark"] .ce-agent-panel-header {
  background: rgba(15, 36, 32, 0.9);
}

/* ── Prezziari bar ─────────────────────────────────────────────────── */
.ce-prezziari-bar {
  flex-shrink: 0;
  border-bottom: 1px solid var(--hairline);
  background: var(--raised);
  position: relative;
}
.ce-prezziari-toggle-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 7px 14px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 13px;
  color: var(--ink-2);
  text-align: left;
}
.ce-prezziari-toggle-btn:hover {
  background: var(--hairline-2);
}
.ce-prezziari-icon { font-size: 14px; }
.ce-prezziari-toggle-label { flex: 1; font-weight: 500; }
.ce-prezziari-active-badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--primary);
  background: var(--color-primary-soft);
  border-radius: 10px;
  padding: 1px 7px;
  min-width: 20px;
  text-align: center;
}
.ce-prezziari-chevron {
  font-size: 11px;
  transition: transform 0.2s;
  color: var(--ink-3);
}
.ce-prezziari-toggle-btn[aria-expanded="true"] .ce-prezziari-chevron {
  transform: rotate(180deg);
}
.ce-prezziari-dropdown {
  padding: 6px 14px 10px;
}
.ce-prezziari-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.ce-prezziari-loading {
  font-size: 12px;
  color: var(--ink-3);
  font-style: italic;
}
.ce-prezziario-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 10px;
  border-radius: var(--r-sm);
  transition: background .15s;
}
.ce-prezziario-item:hover { background: var(--raised); }
:root[data-theme="dark"] .ce-prezziario-item:hover { background: rgba(255,255,255,.03); }
.ce-prezziario-item--disabled {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;  /* blocca click su tutto l'item */
}
.ce-prezziario-item--disabled .ce-prezziario-slider {
  cursor: not-allowed;
}
.ce-prezziario-status-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  font-size: 10px;
  font-weight: 500;
  border-radius: 9px;
  vertical-align: middle;
  text-transform: uppercase;
  letter-spacing: 0.2px;
}
.ce-prezziario-status-badge--processing {
  background: rgba(228, 167, 51, 0.18);
  color: #b07515;
  border: 1px solid rgba(228, 167, 51, 0.35);
}
.ce-prezziario-status-badge--error {
  background: rgba(161, 69, 58, 0.15);
  color: #a1453a;
  border: 1px solid rgba(161, 69, 58, 0.30);
}
:root[data-theme="dark"] .ce-prezziario-status-badge--processing {
  background: rgba(228, 167, 51, 0.20);
  color: #f0c66a;
  border-color: rgba(228, 167, 51, 0.40);
}
:root[data-theme="dark"] .ce-prezziario-status-badge--error {
  background: rgba(220, 100, 90, 0.18);
  color: #f0a094;
  border-color: rgba(220, 100, 90, 0.40);
}
.ce-prezziario-toggle {
  position: relative;
  width: 32px;
  height: 18px;
  flex-shrink: 0;
}
.ce-prezziario-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}
.ce-prezziario-slider {
  position: absolute;
  inset: 0;
  background: var(--hairline);
  border-radius: 18px;
  cursor: pointer;
  transition: background 0.2s;
}
.ce-prezziario-slider::before {
  content: "";
  position: absolute;
  width: 12px; height: 12px;
  left: 3px; bottom: 3px;
  background: var(--raised);
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: var(--shadow-1);
}
.ce-prezziario-toggle input:checked + .ce-prezziario-slider {
  background: var(--primary);
}
.ce-prezziario-toggle input:checked + .ce-prezziario-slider::before {
  transform: translateX(14px);
  background: var(--primary-ink);
}
.ce-prezziario-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ce-prezziario-nome {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.ce-prezziario-meta {
  font-size: 11px;
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ce-prezziari-warn {
  font-size: 11.5px;
  color: #a1453a;
  padding: 8px 10px 2px;
}
.ce-prezziari-hint {
  font-size: 11.5px;
  color: var(--ink-3);
  padding: 8px 10px 2px;
  margin: 0;
}
.ce-prezziario-priority {
  flex: 0 0 auto;
  margin-left: 6px;
}
.ce-prezziario-priority select {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 3px 5px;
  border: 1px solid var(--hairline);
  border-radius: 6px;
  background: var(--raised);
  color: var(--color-text);
  cursor: pointer;
}
.ce-prezziario-priority select:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
:root[data-theme="dark"] .ce-prezziario-priority select {
  background: rgba(255,255,255,.04);
}

/* Lista prezziari inline (pre-generazione computo) */
.gen-prezziari-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 280px;
  overflow-y: auto;
  overflow-x: hidden;
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  padding: 6px;
  background: var(--surface);
}

/* Label di separazione priorità (LOM / DEI) */
.ce-prezziari-tier-label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .14em;
  font-weight: 500;
  color: var(--ink-3);
  margin: 10px 0 4px 10px;
  padding-top: 8px;
  border-top: 1px solid var(--hairline-2);
}
.ce-prezziari-tier-label:first-child {
  margin-top: 2px;
  padding-top: 0;
  border-top: 0;
}

/* --- Catalogo personale servizi a corpo (pannello nel form di generazione) --- */
.svc-catalogo-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: var(--ctl-h);
  padding: 8px 14px;
  background: var(--raised);
  border: 1px solid var(--hairline);
  border-radius: var(--r-sm);
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--color-text);
  text-align: left;
  transition: border-color .2s, background .2s, box-shadow .2s;
}
:root[data-theme="dark"] .svc-catalogo-toggle { background: rgba(255,255,255,.03); }
.svc-catalogo-toggle:hover { border-color: var(--ink-3); box-shadow: var(--shadow-1); }
.svc-catalogo-toggle svg { flex-shrink: 0; color: var(--ink-3); }
.svc-catalogo-toggle span { flex: 1; }
.svc-catalogo-toggle::after {
  content: '›';
  font-size: 18px; line-height: 1;
  color: var(--ink-3);
  transition: transform .2s var(--ease);
}
.svc-catalogo-toggle:hover::after { transform: translateX(3px); }
.svc-catalogo-toggle--open::after { transform: rotate(90deg); }
.svc-catalogo-toggle--open:hover::after { transform: rotate(90deg); }

/* Modale centrata: riusa la base .ce-cloud-modal (posizionamento + backdrop),
   qui solo il dimensionamento largo e il footer. */
.svc-catalogo-modal__panel {
  width: min(760px, 100%);
  max-height: min(84vh, 720px);
  display: flex;
  flex-direction: column;
  padding: 18px 22px 16px;
}
.svc-catalogo-help {
  margin: 0 0 12px;
  font-size: 0.86em;
  line-height: 1.5;
  color: var(--ink-2);
}
.svc-catalogo-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  border: 1px solid var(--hairline);
  border-radius: var(--r-sm);
}
.svc-catalogo-modal__footer {
  display: flex;
  justify-content: flex-end;
  padding-top: 12px;
}
.svc-catalogo-modal__footer .svc-save {
  padding: 7px 22px;
  font-size: 0.9em;
}
.svc-catalogo-msg { font-size: 0.85em; color: var(--ink-2); }
.svc-catalogo-msg--warn { color: var(--gold-ink); }

/* Nota AI discreta (bozza legale, vedi docs/legal/disclaimer-ai.md) — stile
   "ChatGPT può commettere errori": una riga piccola e neutra, non un banner. */
.ai-disclaimer-note {
  font-size: 0.72em;
  line-height: 1.3;
  color: var(--color-text-muted, #9aa0ac);
  text-align: center;
  padding: 4px 8px;
  opacity: 0.85;
}

.svc-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-sans);
}
.svc-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 8px 10px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  text-align: left;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-3);
  background: var(--surface);
  border-bottom: 1px solid var(--hairline);
}
.svc-table td {
  padding: 8px 10px;
  font-size: 0.88em;
  line-height: 1.35;
  color: var(--ink);
  vertical-align: middle;
  border-bottom: 1px solid var(--hairline-2);
}
.svc-table tr:last-child td { border-bottom: 0; }
.svc-actions { white-space: nowrap; }

.svc-inp {
  width: 76px;
  padding: 5px 8px;
  font-size: 0.88em;
  text-align: right;
  font-family: var(--font-mono);
  color: var(--ink);
  background: var(--raised);
  border: 1px solid var(--hairline);
  border-radius: var(--r-sm);
}
.svc-inp:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--focus);
}

.svc-badge-personale {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--primary);
  background: rgba(25, 80, 66, 0.10);
  border-radius: 999px;
}

.svc-save {
  padding: 3px 12px;
  font-size: 0.8em;
  font-weight: 600;
  font-family: var(--font-sans);
  color: var(--primary-ink);
  background: var(--primary);
  border: none;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background .15s ease;
}
.svc-save:hover { background: var(--primary-h); }

.svc-reset {
  padding: 3px 8px;
  font-size: 0.8em;
  background: none;
  color: var(--ink-2);
  border: 1px solid var(--hairline);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: color .15s ease, border-color .15s ease;
}
.svc-reset:hover { color: var(--primary); border-color: var(--primary); }

:root[data-theme="dark"] .ce-prezziari-tier-label {
  color: #d6cabc;
  border-top-color: rgba(214,202,188,0.12);
}
:root[data-theme="dark"] .ce-prezziari-bar {
  background: rgba(15, 36, 32, 0.6);
  border-bottom-color: rgba(214,202,188,0.1);
}
:root[data-theme="dark"] .ce-prezziari-toggle-btn:hover {
  background: rgba(255,255,255,0.04);
}

/* Modalità voce: orb grande centrato, onde fluide (ispirazione voice-first / Perplexity-style) */
.ce-agent-voice-dock {
  flex-shrink: 0;
  padding: 8px 12px 16px;
  border-bottom: 1px solid var(--color-border);
  background: radial-gradient(ellipse 120% 80% at 50% 0%, rgba(25, 80, 66, 0.12) 0%, transparent 55%),
    linear-gradient(180deg, rgba(214, 202, 188, 0.15) 0%, transparent 100%);
}
:root[data-theme="dark"] .ce-agent-voice-dock {
  background: radial-gradient(ellipse 120% 80% at 50% 0%, rgba(56, 189, 248, 0.08) 0%, transparent 50%),
    linear-gradient(180deg, rgba(15, 36, 32, 0.95) 0%, transparent 100%);
}

.ce-voice-dock-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 4px;
}

.ce-voice-orb-stage {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 8px 0 12px;
  min-height: clamp(140px, 32vmin, 200px);
}

/* Variabili colore per stato */
.ce-voice-orb {
  --ce-v-core-a: #195042;
  --ce-v-core-b: #2d6b55;
  --ce-v-wave: rgba(25, 80, 66, 0.35);
  --ce-v-aurora: rgba(25, 80, 66, 0.25);
  --ce-v-sheen: rgba(255, 255, 255, 0.35);
  position: relative;
  width: clamp(112px, 36vw, 148px);
  height: clamp(112px, 36vw, 148px);
  max-width: 148px;
  max-height: 148px;
  border: none;
  padding: 0;
  border-radius: 50%;
  cursor: pointer;
  background: transparent;
  flex-shrink: 0;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  isolation: isolate;
}
.ce-voice-orb:hover {
  transform: scale(1.03);
}
.ce-voice-orb:focus-visible {
  outline: 2px solid var(--color-focus-ring);
  outline-offset: 6px;
}

/* Idle: brand smeraldo */
.ce-voice-orb[data-state="idle"] {
  --ce-v-core-a: #195042;
  --ce-v-core-b: #3d8f76;
  --ce-v-wave: rgba(25, 80, 66, 0.28);
  --ce-v-aurora: rgba(61, 143, 118, 0.2);
}

/* Ascolto: ciano / blu (microfono attivo) */
.ce-voice-orb[data-state="listening"] {
  --ce-v-core-a: #0284c7;
  --ce-v-core-b: #6366f1;
  --ce-v-wave: rgba(56, 189, 248, 0.5);
  --ce-v-aurora: rgba(99, 102, 241, 0.35);
  --ce-v-sheen: rgba(186, 230, 253, 0.45);
}

/* Elaborazione: ambra / viola */
.ce-voice-orb[data-state="processing"] {
  --ce-v-core-a: #d97706;
  --ce-v-core-b: #7c3aed;
  --ce-v-wave: rgba(245, 158, 11, 0.45);
  --ce-v-aurora: rgba(167, 139, 250, 0.35);
  --ce-v-sheen: rgba(254, 243, 199, 0.4);
}

/* Risposta vocale: verde menta */
.ce-voice-orb[data-state="speaking"] {
  --ce-v-core-a: #059669;
  --ce-v-core-b: #34d399;
  --ce-v-wave: rgba(52, 211, 153, 0.55);
  --ce-v-aurora: rgba(16, 185, 129, 0.3);
  --ce-v-sheen: rgba(209, 250, 229, 0.5);
}

/* Sfera WebGPU (liquid-orb.js): sopra tutti i layer CSS, li nasconde quando
   monta con successo. Se WebGPU non c'è o l'init fallisce, .has-gpu-orb non
   viene mai aggiunta e questi due blocchi restano inerti — l'orb CSS sotto
   resta l'unica cosa visibile, invariata. */
.ce-voice-orb-gpu-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  z-index: 4;
  pointer-events: none;
}
.ce-voice-orb.has-gpu-orb .ce-voice-orb-aurora,
.ce-voice-orb.has-gpu-orb .ce-voice-orb-wave,
.ce-voice-orb.has-gpu-orb .ce-voice-orb-sheen,
.ce-voice-orb.has-gpu-orb .ce-voice-orb-core {
  display: none;
}

.ce-voice-orb-aurora {
  position: absolute;
  inset: -28%;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--ce-v-aurora) 0%, transparent 55%);
  filter: blur(18px);
  z-index: 0;
  pointer-events: none;
  opacity: 0.9;
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.ce-voice-orb-wave {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid var(--ce-v-wave);
  opacity: 0;
  z-index: 1;
  pointer-events: none;
  filter: blur(0.5px);
}

.ce-voice-orb-wave--1 { animation: ce-voice-ripple 2.2s cubic-bezier(0.22, 1, 0.36, 1) infinite; }
.ce-voice-orb-wave--2 { animation: ce-voice-ripple 2.2s cubic-bezier(0.22, 1, 0.36, 1) 0.55s infinite; }
.ce-voice-orb-wave--3 { animation: ce-voice-ripple 2.2s cubic-bezier(0.22, 1, 0.36, 1) 1.1s infinite; }

.ce-voice-orb[data-state="listening"] .ce-voice-orb-wave--1 {
  animation-duration: 1.65s;
}
.ce-voice-orb[data-state="listening"] .ce-voice-orb-wave--2 {
  animation-duration: 1.65s;
  animation-delay: 0.35s;
}
.ce-voice-orb[data-state="listening"] .ce-voice-orb-wave--3 {
  animation-duration: 1.65s;
  animation-delay: 0.7s;
}

.ce-voice-orb[data-state="processing"] .ce-voice-orb-wave--1 {
  animation: ce-voice-ripple-tight 1.05s ease-in-out infinite;
}
.ce-voice-orb[data-state="processing"] .ce-voice-orb-wave--2 {
  animation: ce-voice-ripple-tight 1.05s ease-in-out 0.2s infinite;
}
.ce-voice-orb[data-state="processing"] .ce-voice-orb-wave--3 {
  animation: ce-voice-ripple-tight 1.05s ease-in-out 0.4s infinite;
}

.ce-voice-orb[data-state="processing"] .ce-voice-orb-aurora {
  animation: ce-voice-aurora-spin 4s linear infinite;
}

.ce-voice-orb[data-state="speaking"] .ce-voice-orb-wave--1 {
  animation-duration: 2.6s;
}
.ce-voice-orb[data-state="speaking"] .ce-voice-orb-wave--2 {
  animation-duration: 2.6s;
  animation-delay: 0.65s;
}
.ce-voice-orb[data-state="speaking"] .ce-voice-orb-wave--3 {
  animation-duration: 2.6s;
  animation-delay: 1.3s;
}

@keyframes ce-voice-ripple {
  0% {
    transform: scale(0.72);
    opacity: 0.55;
  }
  70% {
    opacity: 0.2;
  }
  100% {
    transform: scale(1.85);
    opacity: 0;
  }
}

@keyframes ce-voice-ripple-tight {
  0% {
    transform: scale(0.88) rotate(0deg);
    opacity: 0.65;
  }
  100% {
    transform: scale(1.35) rotate(180deg);
    opacity: 0;
  }
}

@keyframes ce-voice-aurora-spin {
  to {
    transform: rotate(360deg);
  }
}

.ce-voice-orb-sheen {
  position: absolute;
  inset: 12%;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--ce-v-sheen) 0%, transparent 48%, transparent 52%, rgba(255, 255, 255, 0.08) 100%);
  z-index: 3;
  pointer-events: none;
  mix-blend-mode: overlay;
}

.ce-voice-orb-core {
  position: absolute;
  inset: 14%;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--ce-v-core-a) 0%, var(--ce-v-core-b) 55%, var(--ce-v-core-a) 100%);
  background-size: 200% 200%;
  box-shadow:
    0 4px 28px rgba(15, 23, 42, 0.18),
    0 0 40px rgba(25, 80, 66, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.28);
  z-index: 2;
  transition: box-shadow 0.35s ease, transform 0.2s ease;
}

.ce-voice-orb[data-state="idle"] .ce-voice-orb-core {
  animation: ce-voice-idle-breathe 3.5s ease-in-out infinite;
}

.ce-voice-orb[data-state="listening"] .ce-voice-orb-core {
  animation: ce-voice-core-pulse-listen 1.2s ease-in-out infinite, ce-voice-core-shimmer 3s ease infinite;
}

.ce-voice-orb[data-state="processing"] .ce-voice-orb-core {
  animation: ce-voice-core-pulse-fast 0.75s ease-in-out infinite, ce-voice-core-shimmer 1.8s linear infinite;
}

.ce-voice-orb[data-state="speaking"] .ce-voice-orb-core {
  animation: ce-voice-core-pulse-speak 0.95s ease-in-out infinite, ce-voice-core-shimmer 2.4s ease-in-out infinite;
}

@keyframes ce-voice-idle-breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.025); }
}

@keyframes ce-voice-core-pulse-listen {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}

@keyframes ce-voice-core-pulse-fast {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

@keyframes ce-voice-core-pulse-speak {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}

@keyframes ce-voice-core-shimmer {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* Idle: onde molto leggere */
.ce-voice-orb[data-state="idle"] .ce-voice-orb-wave {
  animation: ce-voice-ripple-soft 3.5s ease-in-out infinite;
  opacity: 0.35;
}
.ce-voice-orb[data-state="idle"] .ce-voice-orb-wave--2 {
  animation-delay: 0.9s;
}
.ce-voice-orb[data-state="idle"] .ce-voice-orb-wave--3 {
  animation-delay: 1.8s;
}

@keyframes ce-voice-ripple-soft {
  0% {
    transform: scale(0.85);
    opacity: 0.25;
  }
  100% {
    transform: scale(1.45);
    opacity: 0;
  }
}

.ce-voice-dock-text {
  text-align: center;
  padding: 0 8px 4px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
}
.ce-voice-status {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
  letter-spacing: 0.01em;
}
.ce-voice-interim {
  font-size: 12px;
  color: var(--color-text-muted);
  min-height: 1.25em;
  font-style: italic;
  word-break: break-word;
  max-width: 100%;
}
.ce-voice-tts-row {
  width: 100%;
  max-width: 280px;
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
}
.ce-voice-tts-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  text-align: center;
}
.ce-voice-tts-select {
  width: 100%;
  padding: 6px 8px;
  font-size: 11px;
  font-family: inherit;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  cursor: pointer;
}

/* Interruttore dell'ascolto continuo. Sta qui, accanto alla voce di lettura,
   perche' e' l'unico posto dove l'utente si occupa gia' di come parla con
   l'assistente. La nota sotto non e' un vezzo: dice dove finisce l'audio, e
   senza quella l'interruttore non sarebbe un consenso informato. */
.ce-voice-wake-row {
  width: 100%;
  max-width: 280px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
}
.ce-voice-wake-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text);
  cursor: pointer;
}
.ce-voice-wake-check {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  accent-color: var(--color-accent, #195042);
  cursor: pointer;
}
.ce-voice-wake-note {
  margin: 0;
  font-size: 11px;
  line-height: 1.45;
  color: var(--color-text-muted);
}
.ce-voice-tts-select:focus-visible {
  outline: 2px solid var(--color-focus-ring);
  outline-offset: 1px;
}
:root[data-theme="dark"] .ce-voice-tts-select {
  background: var(--color-surface-raised, #1c2e2a);
}
.ce-voice-exit-btn {
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 600;
  font-family: inherit;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text-muted);
  cursor: pointer;
}
.ce-voice-exit-btn:hover {
  background: var(--color-bg);
  color: var(--color-text);
}

@media (prefers-reduced-motion: reduce) {
  .ce-voice-orb .ce-voice-orb-wave,
  .ce-voice-orb .ce-voice-orb-aurora,
  .ce-voice-orb .ce-voice-orb-core {
    animation: none !important;
  }
  .ce-voice-orb[data-state="idle"] .ce-voice-orb-wave {
    opacity: 0.2;
    transform: scale(1);
  }
}

.ce-agent-panel-title {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: 16.5px;
  letter-spacing: -0.005em;
  color: var(--color-text);
}
.ce-agent-close {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--color-text-muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.ce-agent-close:hover {
  background: var(--hairline-2);
  color: var(--color-text);
}
.ce-agent-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}
.ce-agent-msg {
  max-width: 92%;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}
.ce-agent-msg--user {
  align-self: flex-end;
  background: var(--color-primary);
  color: #fff;
}
.ce-agent-msg--assistant {
  align-self: flex-start;
  background: var(--raised);
  color: var(--color-text);
  border: 1px solid var(--hairline);
}
.ce-agent-msg--error {
  align-self: flex-start;
  background: rgba(161, 69, 58, 0.1);
  color: #a1453a;
  border: 1px solid rgba(161, 69, 58, 0.3);
}

.ce-agent-thinking {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 9px;
  border: 1px solid var(--color-border);
  background: var(--color-primary-soft);
  color: var(--color-primary);
  font-size: 12.5px;
}

.ce-agent-thinking-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: ce-btn-spin .75s linear infinite;
  flex-shrink: 0;
}
@media (prefers-reduced-motion: reduce) {
  .ce-agent-thinking-spinner { animation: none; }
}

.ce-agent-thinking-text {
  font-weight: 600;
}
.ce-agent-input-wrap {
  flex-shrink: 0;
  padding: 12px;
  border-top: 1px solid var(--color-border);
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.ce-agent-attachments-list {
  display: none;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 12px 0;
  background: var(--color-bg);
}
.ce-agent-att-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 4px 8px;
  border-radius: 14px;
  border: 1px solid var(--color-border);
  background: var(--color-primary-soft);
  color: var(--color-primary);
  font-size: 12px;
  font-weight: 600;
}
.ce-agent-att-name {
  max-width: 210px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ce-agent-att-remove {
  border: none;
  background: transparent;
  color: var(--color-primary);
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
}
.ce-agent-icon-btn {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border: 1px solid var(--hairline);
  border-radius: var(--r-sm);
  background: var(--raised);
  color: var(--color-text-muted);
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.ce-agent-icon-btn:hover {
  background: var(--color-primary-soft);
  border-color: rgba(25, 80, 66, 0.35);
  color: var(--color-primary);
}
.ce-agent-icon-btn.active {
  background: rgba(161, 69, 58, 0.12);
  border-color: rgba(161, 69, 58, 0.35);
  color: #a1453a;
}
.ce-agent-input {
  flex: 1;
  min-height: 44px;
  max-height: 120px;
  padding: 10px 12px;
  border: 1px solid var(--hairline);
  border-radius: var(--r-sm);
  background: var(--raised);
  color: var(--color-text);
  font-family: inherit;
  font-size: 14px;
  resize: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.ce-agent-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--focus);
}
.ce-agent-send {
  flex-shrink: 0;
  padding: 10px 18px;
  border: none;
  border-radius: var(--r-sm);
  background: var(--color-primary);
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}
.ce-agent-send:hover:not(:disabled) {
  background: var(--color-primary-h);
}
.ce-agent-send:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.ce-agent-mic-status {
  padding: 0 12px 10px;
  color: #a1453a;
  font-size: 12px;
  font-weight: 600;
}

/* ---------------------------------------------------------------------------
   Relazioni tecniche (NEW LAYOUT)
--------------------------------------------------------------------------- */
.computi-rel-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100%;
  background: var(--bg);
  padding: 18px;
  box-sizing: border-box;
  overflow: hidden;
}

.computi-rel-grid {
  display: grid;
  grid-template-columns: 3fr 4.5fr 2.5fr;
  gap: 18px;
  flex: 1;
  min-height: 0;
  width: 100%;
}

@media (max-width: 1024px) {
  .computi-rel-grid {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    overflow-y: auto;
  }
}

/* LEFT COLUMN: CHAT */
.computi-rel-col-left {
  background: var(--surface);
  border-radius: var(--r-md);
  border: 1px solid var(--hairline);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 18px;
  box-shadow: none;
}

.computi-rel-progress {
  margin-bottom: 4px;
}

#relazione-progress-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 8px;
}

.computi-rel-progress-bar {
  height: 3px;
  background: var(--hairline-2);
  border-radius: 2px;
  overflow: hidden;
}

#relazione-progress-fill {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--brand-accent));
  width: 0%;
  border-radius: 2px;
  transition: width 0.6s var(--ease);
}

.computi-rel-col-title {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: 19px;
  letter-spacing: -0.01em;
  color: var(--color-text);
  margin: 14px 0 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--hairline-2);
}

.computi-rel-chat-messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 12px;
  padding-right: 6px;
}

.computi-rel-msg {
  padding: 11px 14px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.55;
  max-width: 90%;
}

.computi-rel-msg--assistant {
  background: var(--raised);
  border: 1px solid var(--hairline-2);
  color: var(--color-text);
  align-self: flex-start;
  border-bottom-left-radius: 5px;
}
:root[data-theme="dark"] .computi-rel-msg--assistant { background: rgba(255,255,255,.04); }

.computi-rel-msg--user {
  background: var(--primary);
  color: var(--primary-ink);
  align-self: flex-end;
  border-bottom-right-radius: 5px;
}
.msg-tavole { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tav-chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-mono); font-size: 10.5px;
  color: var(--primary-ink); opacity: .9;
  border: 1px solid rgba(245,241,232,.35); border-radius: 999px; padding: 3px 10px;
  background: rgba(245,241,232,.1);
}
.tav-chip svg { color: var(--brand-sand); flex-shrink: 0; }

.computi-rel-chat-footer {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.computi-rel-chat-input {
  background: var(--raised);
  border: 1px solid var(--hairline);
  border-radius: var(--r-sm);
  padding: 10px 13px;
  transition: border-color 0.2s, box-shadow .2s;
}
:root[data-theme="dark"] .computi-rel-chat-input { background: rgba(255,255,255,.04); }

.computi-rel-chat-input:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--focus);
}

#relazione-chat-input {
  width: 100%;
  border: none;
  background: transparent;
  resize: none;
  font-family: var(--font-sans);
  font-size: 13.5px;
  color: var(--color-text);
  outline: none;
}
#relazione-chat-input::placeholder { color: var(--ink-3); }

.computi-rel-chat-actions {
  display: flex;
  gap: 10px;
}

.computi-rel-chat-actions button {
  flex: 1;
  min-height: var(--ctl-h);
  padding: 0 14px;
  border-radius: var(--r-sm);
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  border: none;
  transition: opacity 0.2s, background .2s var(--ease), transform .2s var(--ease), box-shadow .25s var(--ease);
}

#relazione-generate-btn {
  background: var(--primary);
  color: var(--primary-ink);
}
#relazione-generate-btn:not(:disabled):hover { background: var(--primary-h); transform: translateY(-1px); box-shadow: var(--shadow-2); }

#relazione-generate-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

#relazione-chat-send {
  background: var(--primary);
  color: var(--primary-ink);
}
#relazione-chat-send:hover { background: var(--primary-h); }

/* CENTER COLUMN: PREVIEW */
.computi-rel-col-center {
  background: var(--surface);
  border-radius: var(--r-md);
  border: 1px solid var(--hairline);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
  box-shadow: none;
}

.computi-rel-viewer-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 13px 18px;
  border-bottom: 1px solid var(--hairline-2);
  background: var(--surface);
}

.computi-rel-viewer-title-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.computi-rel-viewer-title {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--color-text);
}

.computi-coming-subtitle {
  font-size: 11.5px;
  color: var(--ink-3);
}

#relazione-save-pdf-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 14px;
  background: transparent;
  border: 1px solid var(--hairline);
  border-radius: var(--r-sm);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: 13px;
  cursor: pointer;
  transition: border-color .2s, box-shadow .2s;
}

#relazione-save-pdf-btn:not(:disabled):hover {
  border-color: var(--ink-3);
  box-shadow: var(--shadow-1);
}

.computi-rel-viewer-content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: clamp(16px, 2.5vw, 30px);
  background: var(--bg);
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px),
    linear-gradient(rgba(145,133,90,.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(145,133,90,.07) 1px, transparent 1px);
  background-size: 8px 8px, 8px 8px, 40px 40px, 40px 40px;
  -webkit-overflow-scrolling: touch;
}

/* Layout/tipografia definitivi in fondo al file: vedi seconda occorrenza
   di .relazione-md-preview (la "carta" con motivo a carta millimetrata). */

.rel-md-empty {
  color: var(--color-text-muted);
  font-style: italic;
  text-align: center;
  margin-top: 40px;
}

/* RIGHT COLUMN: ACTIONS & INFO */
.computi-rel-col-right {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.computi-rel-card {
  background: var(--surface);
  border-radius: var(--r-md);
  border: 1px solid var(--hairline);
  padding: 16px 17px;
  box-shadow: none;
}
.computi-rel-col-right .computi-rel-card + .computi-rel-card { margin-top: 18px; }

.computi-rel-card--flex {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.computi-rel-card-title {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 13px;
}

.computi-rel-upload-zone {
  border: 1.5px dashed var(--hairline);
  border-radius: var(--r-sm);
  padding: 18px 14px;
  text-align: center;
  background: var(--raised);
  transition: border-color .25s var(--ease), background .25s var(--ease);
}
:root[data-theme="dark"] .computi-rel-upload-zone { background: rgba(255,255,255,.03); }

.computi-rel-upload-zone:hover {
  border-color: var(--brand-accent);
  background: var(--surface);
}
:root[data-theme="dark"] .computi-rel-upload-zone:hover { background: rgba(255,255,255,.05); }

.computi-rel-upload-zone p {
  font-size: 13px;
  color: var(--color-text-muted);
  margin-bottom: 12px;
}

#relazione-tavole-btn {
  min-height: 40px;
  padding: 0 16px;
  background: var(--raised);
  border: 1px solid var(--hairline);
  color: var(--color-text);
  border-radius: var(--r-sm);
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: border-color .2s, box-shadow .2s;
  width: 100%;
}

#relazione-tavole-btn:hover {
  border-color: var(--ink-3);
  box-shadow: var(--shadow-1);
}

.computi-rel-field {
  margin-bottom: 14px;
}

.computi-rel-field label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--color-text-muted);
  margin-bottom: 7px;
}

.computi-rel-field input {
  width: 100%;
  min-height: var(--ctl-h);
  padding: 0 13px;
  border: 1px solid var(--hairline);
  border-radius: var(--r-sm);
  background: var(--raised);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: 14px;
  transition: border-color .2s, box-shadow .2s;
}
:root[data-theme="dark"] .computi-rel-field input { background: rgba(255,255,255,.04); }

.computi-rel-field input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--focus);
}

.computi-rel-actions-bottom {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.computi-rel-actions-bottom button {
  width: 100%;
  min-height: var(--ctl-h);
  padding: 0 16px;
  border-radius: var(--r-sm);
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  border: none;
  transition: opacity 0.2s, background .2s var(--ease), transform .2s var(--ease), box-shadow .25s var(--ease);
}

#relazione-to-computo-btn {
  background: var(--primary);
  color: var(--primary-ink);
}
#relazione-to-computo-btn:not(:disabled):hover { background: var(--primary-h); transform: translateY(-1px); box-shadow: var(--shadow-2); }

#relazione-to-computo-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

#relazione-edit-send {
  background: transparent;
  border: 1px solid var(--hairline);
  color: var(--color-text);
}
#relazione-edit-send:not(:disabled):hover { border-color: var(--ink-3); background: var(--surface); }

#relazione-edit-send:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Old classes to remove/override */
.computi-rel-head,
.computi-rel-hint,
.computi-rel-upload-row,
.computi-rel-mobile-tabs,
.computi-rel-mobile-tab,
.computi-rel-doc-column,
.computi-rel-pane-label,
.computi-rel-pane-label--pdf,
.computi-rel-pdf-block,
.computi-rel-pdf-frame-wrap,
.computi-rel-pdf-iframe,
.computi-rel-pdf-fallback,
.computi-rel-viewer-footer {
  display: none !important;
}

/* Old classes to remove/override */
.computi-rel-head,
.computi-rel-hint,
.computi-rel-upload-row,
.computi-rel-mobile-tabs,
.computi-rel-mobile-tab,
.computi-rel-doc-column,
.computi-rel-pane-label,
.computi-rel-pane-label--pdf,
.computi-rel-pdf-block,
.computi-rel-pdf-frame-wrap,
.computi-rel-pdf-iframe,
.computi-rel-pdf-fallback,
.computi-rel-viewer-footer {
  display: none !important;
}
/* Card MCQ dentro l'area messaggi: risposte selezionabili stile Claude */
.computi-rel-msg--mcq {
  align-self: stretch;
  max-width: 92%;
  background: transparent;
  border: none;
  padding: 0;
  border-radius: 0;
}
.computi-rel-msg--mcq.relazione-mcq-card--submitted {
  opacity: 0.55;
  pointer-events: none;
}
.relazione-mcq-box {
  border: none;
  border-radius: 0;
  padding: 0;
  margin-bottom: 14px;
  background: transparent;
}
.relazione-mcq-q-title {
  font-weight: 600;
  font-size: 13.5px;
  margin: 0 0 4px;
  color: var(--color-text);
}
.relazione-mcq-help {
  font-size: 12px;
  color: var(--ink-3);
  margin: 0 0 8px;
}
.relazione-mcq-opts {
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.relazione-mcq-opts label {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  font-family: var(--font-sans);
  font-size: 13.5px;
  color: var(--color-text);
  background: var(--raised);
  border: 1px solid var(--hairline);
  border-radius: 11px;
  padding: 10px 13px;
  margin: 0;
  cursor: pointer;
  transition: border-color .2s var(--ease), background .2s, transform .2s var(--ease);
}
:root[data-theme="dark"] .relazione-mcq-opts label { background: rgba(255,255,255,.04); }
.relazione-mcq-opts label:hover { border-color: var(--brand-accent); transform: translateX(3px); }

.relazione-mcq-opts input[type="radio"],
.relazione-mcq-opts input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  margin: 0;
  border: 1.5px solid var(--ink-3);
  border-radius: 50%;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
}
.relazione-mcq-opts input[type="checkbox"] { border-radius: 5px; }
.relazione-mcq-opts input[type="radio"]::after,
.relazione-mcq-opts input[type="checkbox"]::after {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--primary-ink);
  transform: scale(0);
  transition: transform .2s var(--ease);
}
.relazione-mcq-opts input[type="checkbox"]::after { border-radius: 2px; }
.relazione-mcq-opts label:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary);
  color: var(--primary-ink);
}
.relazione-mcq-opts label:has(input:checked) input {
  border-color: var(--primary-ink);
  background: transparent;
}
.relazione-mcq-opts label:has(input:checked) input::after {
  transform: scale(1);
}
.relazione-mcq-other {
  width: 100%;
  margin-top: 8px;
  min-height: 40px;
  font-family: var(--font-sans);
  font-size: 13px;
  padding: 0 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--hairline);
  background: var(--raised);
  color: var(--color-text);
  transition: border-color .2s, box-shadow .2s;
}
:root[data-theme="dark"] .relazione-mcq-other { background: rgba(255,255,255,.04); }
.relazione-mcq-other:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--focus); }
.relazione-mcq-submit {
  margin-top: 4px;
}
:root[data-theme="dark"] .relazione-mcq-help {
  color: var(--ink-3);
}

/* -------------------------------------------------------------------------- */
/* Q&A pre-generazione computo: modal a tutto schermo                          */
/* -------------------------------------------------------------------------- */
.computi-clarify-overlay {
  position: fixed;
  inset: 0;
  background: rgba(16, 32, 29, 0.55);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9000;
  padding: 24px;
  animation: clarifyFadeIn 0.18s ease-out;
}
@keyframes clarifyFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.computi-clarify-modal {
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-2);
  width: min(640px, 100%);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--hairline);
  animation: mq-rise .45s var(--ease) both;
}
.computi-clarify-header {
  padding: 20px 24px 14px;
  border-bottom: 1px solid var(--hairline);
}
.computi-clarify-title {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: 22px;
  letter-spacing: -0.01em;
  margin: 0 0 4px;
  color: var(--ink);
}
.computi-clarify-subtitle {
  font-size: 13px;
  color: var(--ink-2);
  margin: 0;
  line-height: 1.5;
}
.computi-clarify-comprensione {
  margin: 16px 24px 4px;
  padding: 12px 14px;
  background: rgba(145, 133, 90, 0.08);
  border-left: 3px solid var(--brand-accent);
  border-radius: var(--r-sm);
  font-size: 12.5px;
}
.computi-clarify-comprensione-label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.14em;
  color: var(--gold-ink);
  text-transform: uppercase;
  margin-bottom: 5px;
}
.computi-clarify-comprensione-text {
  color: var(--ink);
  line-height: 1.5;
  white-space: pre-wrap;
}
.computi-clarify-body {
  padding: 18px 24px;
  overflow-y: auto;
  flex: 1 1 auto;
}
.computi-clarify-footer {
  padding: 14px 24px;
  border-top: 1px solid var(--hairline);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}
.computi-rel-chat-input {
  padding: 8px 12px 4px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.computi-rel-chat-input textarea {
  width: 100%;
  resize: none;
  height: 52px;
  border: 1px solid var(--hairline);
  border-radius: var(--r-sm);
  padding: 8px 10px;
  font-family: var(--font-sans);
  font-size: 13px;
  background: var(--raised);
  color: var(--ink);
}
.computi-rel-chat-actions {
  padding: 4px 12px 8px;
}
/* ---- Viewer: flex layout definitivo ---- */
.computi-rel-viewer-toolbar {
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px 12px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--hairline-2);
  background: var(--surface);
}
.computi-rel-viewer-title {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--ink);
  flex: 1 1 auto;
  min-width: 0;
}
.computi-rel-viewer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  flex: 1 1 auto;
  min-width: 0;
}
.computi-rel-viewer-content {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  border-bottom: none;
  background-color: var(--bg);
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px),
    linear-gradient(rgba(145,133,90,.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(145,133,90,.07) 1px, transparent 1px);
  background-size: 8px 8px, 8px 8px, 40px 40px, 40px 40px;
  padding: clamp(16px, 2.5vw, 30px);
  -webkit-overflow-scrolling: touch;
}

.computi-rel-doc-column {
  display: flex;
  flex-direction: column;
  flex: 1 1 0;
  min-height: 0;
  min-width: 0;
}

.computi-rel-pdf-block {
  display: flex;
  flex-direction: column;
  flex: 1 1 0;
  min-height: 140px;
  min-width: 0;
  border-top: 1px solid var(--hairline);
}

.computi-rel-pane-label--pdf {
  background: rgba(145, 133, 90, 0.10);
  color: var(--gold-ink);
  border-color: rgba(145, 133, 90, 0.30);
}

.computi-rel-pdf-frame-wrap {
  position: relative;
  flex: 1 1 0;
  min-height: 200px;
  min-width: 0;
  background: var(--raised);
}

.computi-rel-pdf-iframe {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 200px;
  border: 0;
  /* la pagina PDF resta "carta" chiara in entrambi i temi, come l'anteprima della relazione */
  background: #fff;
}

.computi-rel-pdf-fallback {
  margin: 0;
  padding: 16px;
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--ink-3);
  text-align: center;
}
.computi-rel-viewer-footer {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-top: 1px solid var(--hairline);
  background: var(--surface);
}
.computi-rel-viewer-footer textarea {
  flex: 1;
  resize: none;
  height: 36px;
  border: 1px solid var(--hairline);
  border-radius: var(--r-sm);
  padding: 6px 10px;
  font-family: var(--font-sans);
  font-size: 13px;
  background: var(--raised);
  color: var(--ink);
}

.computi-rel-pane-label {
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-3);
  padding: 8px 12px 4px;
  background: var(--surface);
  border-bottom: 1px solid var(--hairline-2);
}

.relazione-md-preview {
  flex: 0 0 auto;
  width: 100%;
  max-width: 680px;
  min-height: 120px;
  margin: 0 auto;
  padding: clamp(24px, 4vw, 48px);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.75;
  color: #22302c;
  background: #fdfbf7;
  border: 1px solid var(--hairline);
  border-radius: 4px;
  box-shadow: var(--shadow-1);
  box-sizing: border-box;
}
:root[data-theme="dark"] .relazione-md-preview { background: #f2ede2; color: #22302c; }

.relazione-md-preview .rel-md-empty {
  margin: 0;
  color: var(--ink-3);
  font-size: 13px;
  font-style: italic;
}

.relazione-md-preview .rel-md-h1 {
  margin: 0.1em 0 0.5em;
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: 1.7rem;
  letter-spacing: -0.01em;
  line-height: 1.22;
  color: #1d3937;
  border-bottom: 1px solid rgba(29,57,55,.14);
  padding-bottom: 0.4em;
}

.relazione-md-preview .rel-md-h2 {
  margin: 1.2em 0 0.45em;
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 1.15rem;
  color: #1d3937;
}

.relazione-md-preview .rel-md-h3 {
  margin: 1em 0 0.35em;
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 1.02rem;
  color: #33453f;
}

.relazione-md-preview .rel-md-p {
  margin: 0 0 0.85em;
  max-width: 68ch;
}

.relazione-md-preview .rel-md-ul,
.relazione-md-preview .rel-md-ol {
  margin: 0 0 0.85em 0;
  padding-left: 1.35em;
}

.relazione-md-preview .rel-md-ul li,
.relazione-md-preview .rel-md-ol li {
  margin: 0.3em 0;
}

.relazione-md-preview .rel-md-hr {
  border: 0;
  border-top: 1px solid rgba(29,57,55,.14);
  margin: 1.2em 0;
}

.relazione-md-preview .rel-md-table-wrap {
  overflow-x: auto;
  margin: 0.9em 0 1.1em;
  border-radius: 8px;
  border: 1px solid rgba(29,57,55,.14);
  background: #fff;
  box-shadow: var(--shadow-1);
}

.relazione-md-preview .rel-md-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}

.relazione-md-preview .rel-md-table th,
.relazione-md-preview .rel-md-table td {
  border: 1px solid rgba(29,57,55,.1);
  padding: 9px 12px;
  text-align: left;
  vertical-align: top;
}

.relazione-md-preview .rel-md-table th {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: .06em;
  text-transform: uppercase;
  background: rgba(29,57,55,.05);
  font-weight: 500;
  color: #1d3937;
}

.relazione-md-preview .rel-md-table tbody tr:nth-child(even) {
  background: rgba(145,133,90,.05);
}

.relazione-md-preview .rel-md-code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: rgba(29,57,55,.06);
  padding: 0.15em 0.4em;
  border-radius: 4px;
}

.relazione-md-preview .rel-md-spacer {
  height: 0.4em;
}

@media (max-width: 1024px) {
  .computi-rel-pdf-frame-wrap {
    min-height: min(220px, 32dvh);
  }
}

@supports not (height: 1dvh) {
  @media (max-width: 1024px) {
    .computi-rel-pdf-frame-wrap {
      min-height: 220px;
    }
  }
}

@media (max-width: 768px) {
  #computi-coming-view .computi-rel-chat-input textarea,
  #computi-coming-view .computi-rel-viewer-footer textarea {
    font-size: 16px;
  }
  #computi-coming-view .computi-send-btn {
    min-height: 44px;
    min-width: 48px;
    padding: 0 14px;
    width: 100%;
    box-sizing: border-box;
  }
  #computi-coming-view .computi-rel-viewer-footer {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  #computi-coming-view .computi-rel-viewer-footer textarea {
    flex: none;
    width: 100%;
    min-height: 48px;
    box-sizing: border-box;
  }
  #computi-coming-view .computi-rel-viewer-footer .computi-excel-btn {
    min-height: 44px;
    padding: 0 14px;
    width: 100%;
    box-sizing: border-box;
  }
  #computi-coming-view .computi-rel-chat-actions .computi-choice-btn {
    min-height: 44px;
    width: 100%;
    box-sizing: border-box;
  }
  #computi-coming-view .computi-rel-mobile-tab {
    min-height: 44px;
  }
  #computi-coming-view .computi-rel-viewer-toolbar .computi-project-btn,
  #computi-coming-view .computi-rel-viewer-toolbar .computi-choice-btn {
    min-height: 44px;
    flex: 1 1 calc(50% - 4px);
    min-width: min(100%, 140px);
  }
  #computi-coming-view .computi-rel-viewer-actions {
    width: 100%;
    justify-content: space-between;
  }
}

.computi-rel-edit-row {
  padding: 10px 12px;
  display: flex;
  gap: 8px;
  background: var(--surface);
  flex-shrink: 0;
}
.computi-rel-edit-row textarea {
  flex: 1;
  resize: vertical;
  min-height: 64px;
  border: 1px solid var(--hairline);
  border-radius: var(--r-sm);
  padding: 10px;
  font-family: var(--font-sans);
  font-size: 13px;
  background: var(--raised);
  color: var(--ink);
}
@media (max-width: 1024px) {
  .computi-gate--coming {
    padding: 8px;
    padding-bottom: max(8px, env(safe-area-inset-bottom, 0px));
  }
  .computi-rel-shell {
    border-radius: 8px;
    padding: 12px;
    padding-bottom: max(12px, env(safe-area-inset-bottom, 0px));
    max-width: 100%;
  }
  .computi-rel-head {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  .computi-rel-head .computi-choice-btn {
    width: 100%;
    min-height: 44px;
    box-sizing: border-box;
  }
  .computi-rel-upload-row {
    flex-direction: column;
    align-items: stretch;
  }
  .computi-rel-upload-row .computi-choice-btn {
    width: 100%;
    min-height: 44px;
    box-sizing: border-box;
  }
  .computi-rel-upload-row .computi-rel-hint {
    margin: 0 !important;
  }
  .computi-rel-grid {
    flex-direction: column;
  }
  .computi-rel-mobile-tabs {
    display: flex;
  }
  .computi-rel-grid.mode-chat .computi-rel-viewer {
    display: none !important;
  }
  .computi-rel-grid.mode-viewer .computi-rel-chat {
    display: none !important;
  }
  .computi-rel-chat,
  .computi-rel-viewer {
    flex: 1 1 0 !important;
    min-height: 0;
    min-width: 0;
    max-height: 100%;
  }
  #computi-coming-view .computi-rel-viewer-toolbar .computi-project-btn,
  #computi-coming-view .computi-rel-viewer-toolbar .computi-choice-btn {
    min-height: 44px;
  }
}

/* ---------------------------------------------------------------------------
   Computi responsive (tablet/mobile) - desktop invariato
--------------------------------------------------------------------------- */
@media (max-width: 1024px) {
  #section-computi.active {
    min-height: calc(100dvh - 57px);
  }

  /* Login split: non forzare scroll della gate (regola generica sotto) */
  body.computi-login-screen #section-computi .computi-gate:not(.computi-gate--coming):not(.computi-gate--choice) {
    overflow-y: auto;
    overflow-x: hidden;
    align-items: stretch;
    justify-content: stretch;
    padding-top: 0;
    padding-bottom: 0;
  }

  #section-computi .computi-gate:not(.computi-gate--coming) {
    align-items: flex-start;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-top: 16px;
    padding-bottom: 20px;
  }

  #section-computi .computi-choice-layout {
    width: 100%;
    max-width: 100%;
  }

  #section-computi .computi-history-panel {
    max-width: 100%;
    min-height: 240px;
    max-height: none;
  }

  #section-computi #computi-app-shell {
    height: calc(100dvh - 57px);
    min-height: calc(100dvh - 57px);
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
  }

  /* Evita che le righe auto si stirino a riempire il viewport: altrimenti il pannello
     config resta schiacciato (overflow:hidden) e spariscono dropzone / Analizza. */
  #section-computi .computi-wrapper {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
    min-height: 0;
    height: auto;
    align-content: start;
    max-width: 100%;
    box-sizing: border-box;
  }

  #section-computi .computi-config-panel {
    border-right: none;
    border-bottom: 1px solid var(--color-border);
    padding: 14px 12px;
    gap: 12px;
    max-height: none;
    overflow-x: hidden;
    overflow-y: auto;
    min-width: 0;
  }

  #section-computi .computi-nav-row {
    justify-content: space-between;
  }

  #section-computi .computi-left-toggle-btn,
  #section-computi .computi-left-expand-btn {
    display: none !important;
  }

  #section-computi .computi-result-panel {
    min-height: 240px;
    overflow: visible;
    min-width: 0;
    max-width: 100%;
  }

  #section-computi .computi-desc,
  #section-computi .computi-project-hint,
  #section-computi .computi-label {
    overflow-wrap: break-word;
    word-wrap: break-word;
    word-break: break-word;
    max-width: 100%;
  }

  #section-computi .computi-title {
    min-width: 0;
    flex-wrap: wrap;
  }

  #section-computi .computi-dropzone {
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
  }

  #section-computi .dropzone-text,
  #section-computi .dropzone-hint {
    overflow-wrap: break-word;
    word-break: break-word;
    max-width: 100%;
  }

  #section-computi .computi-textarea,
  #section-computi .computi-select,
  #section-computi .computi-send-btn,
  #section-computi .computi-project-btn {
    max-width: 100%;
    box-sizing: border-box;
  }

  #section-computi .computi-empty,
  #section-computi .computi-loading {
    flex: 0 1 auto;
    min-height: 200px;
    max-height: min(42dvh, 360px);
    padding: 20px 14px;
    box-sizing: border-box;
  }

  @supports not (height: 1dvh) {
    #section-computi .computi-empty,
    #section-computi .computi-loading {
      max-height: min(42vh, 360px);
    }
  }

  #section-computi .computo-editor-section {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr) auto;
    min-height: 0;
  }

  #section-computi .ce-change-nav-btn,
  #section-computi .ce-change-nav-close {
    min-width: 44px;
    min-height: 44px;
  }

  #section-computi .computo-editor-section.computo-editor-section--agent-open {
    grid-template-columns: 1fr;
  }

  #section-computi .ce-toolbar {
    padding: 10px 12px;
  }

  #section-computi .ce-toolbar-left,
  #section-computi .ce-toolbar-right {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  #section-computi .ce-table-wrap {
    overflow: auto;
    overscroll-behavior: contain;
  }

  #section-computi .ce-scroll {
    min-width: 760px;
  }

  #section-computi .ce-agent-resize-handle {
    display: none;
  }

  #section-computi .ce-agent-panel {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: 57px;
    width: auto;
    height: auto;
    border-left: none;
    border-top: 1px solid var(--color-border);
    box-shadow: 0 -12px 28px rgba(15, 23, 42, 0.2);
    transform: translateY(100%);
    grid-column: 1;
    grid-row: 1 / -1;
    z-index: 250;
  }

  #section-computi .ce-agent-panel.ce-agent-panel--open {
    transform: translateY(0);
  }

  #section-computi .ce-agent-input-wrap {
    padding: 10px;
    align-items: stretch;
  }

  #section-computi .ce-agent-icon-btn,
  #section-computi .ce-agent-send {
    height: 40px;
  }

  #section-computi .ce-agent-input {
    max-height: 140px;
  }
}

@media (max-width: 768px) {
  #section-computi .computi-gate {
    padding: 14px;
    padding-bottom: max(18px, env(safe-area-inset-bottom, 0px));
  }

  body.computi-login-screen #section-computi .computi-gate:not(.computi-gate--coming):not(.computi-gate--choice) {
    padding: 0;
    padding-bottom: 0;
  }

  #section-computi .computi-choice-layout {
    flex-direction: column;
    gap: 14px;
    max-width: 100%;
  }

  #section-computi .computi-choice-main.computi-gate-card,
  #section-computi .computi-gate-card {
    padding: 18px 14px;
    border-radius: 12px;
  }

  #section-computi .computi-choice-main h2 {
    font-size: 26px;
  }

  #section-computi .computi-choice-main p {
    font-size: 14px;
  }

  #section-computi .computi-choice-top {
    flex-direction: column;
    align-items: stretch;
  }

  #section-computi .computi-choice-btn--resume {
    width: 100%;
    max-width: none;
  }

  #section-computi .computi-mode-toggle {
    position: sticky;
    top: 0;
    z-index: 4;
    background: var(--color-surface);
  }

  #section-computi .mode-btn {
    min-height: 42px;
    font-size: 13.5px;
    font-weight: 600;
  }

  #section-computi .computi-result-header {
    padding: 10px 12px;
    gap: 8px;
    flex-wrap: wrap;
  }

  #section-computi .computi-result-body {
    padding: 14px 12px;
  }

  #section-computi .ce-scroll {
    min-width: 680px;
  }
}

/* ---------------------------------------------------------------------------
   Tema scuro: celle tabella computo e shell relazione (contrasto lettura)
--------------------------------------------------------------------------- */
:root[data-theme="dark"] .ce-td {
  border-color: rgba(214, 202, 188, 0.12);
  color: var(--color-text);
}
:root[data-theme="dark"] .ce-row-desc {
  background: var(--color-surface);
}
:root[data-theme="dark"] .ce-td-computed {
  background: #121c1a;
  color: var(--color-text-muted);
}
:root[data-theme="dark"] .ce-row-mis {
  background: #141f1d;
}
:root[data-theme="dark"] .ce-row-mis-hdr {
  background: #1a2624;
}
:root[data-theme="dark"] .ce-mis-label {
  color: #c8d5ce;
}
:root[data-theme="dark"] .ce-td-nota {
  color: #c2cec8;
}
:root[data-theme="dark"] .ce-row-add-mis td {
  background: #172523;
  border-color: rgba(214, 202, 188, 0.18);
}
:root[data-theme="dark"] .ce-btn-add-mis {
  color: #b9c5be;
  border-color: rgba(214, 202, 188, 0.3);
}
:root[data-theme="dark"] .ce-btn-add-mis:hover {
  background: rgba(25, 80, 66, 0.35);
  color: #e7eee9;
}
:root[data-theme="dark"] .ce-btn-add-label {
  color: #d6cabc;
  border-color: rgba(214, 202, 188, 0.45);
}
:root[data-theme="dark"] .ce-btn-add-label:hover {
  background: rgba(145, 133, 90, 0.22);
  color: #f2ece2;
}
:root[data-theme="dark"] .ce-row-sommano {
  background: #1d3c34;
}
:root[data-theme="dark"] .ce-sommano-um,
:root[data-theme="dark"] .ce-td-importo {
  color: #daf4e9;
}
:root[data-theme="dark"] .ce-row-sep td {
  background: #13211f;
}
:root[data-theme="dark"] .ce-add-voce-wrap {
  background: #14211f;
  border-top-color: rgba(214, 202, 188, 0.2);
}
:root[data-theme="dark"] .ce-btn-add-voce {
  background: rgba(25, 80, 66, 0.32);
  border-color: rgba(142, 207, 184, 0.45);
  color: #d5ebe2;
}
:root[data-theme="dark"] .ce-btn-add-voce:hover {
  background: rgba(25, 80, 66, 0.5);
  color: #edf6f2;
}
:root[data-theme="dark"] .ce-toolbar {
  background: #112a25;
  box-shadow: inset 0 -1px 0 rgba(214, 202, 188, 0.12);
}
:root[data-theme="dark"] .ce-table-wrap {
  background: #101d1b;
}
:root[data-theme="dark"] .ce-row-desc {
  background: #182826;
}
:root[data-theme="dark"] .ce-row-macro {
  background: #27423d;
}
:root[data-theme="dark"] .ce-td-macro {
  border-top-color: rgba(214, 202, 188, 0.2);
  border-bottom-color: rgba(214, 202, 188, 0.2);
}
:root[data-theme="dark"] .ce-agent-panel {
  background: #13221f;
  border-left-color: rgba(214, 202, 188, 0.18);
}
:root[data-theme="dark"] .ce-agent-panel.ce-agent-panel--open {
  border-left-color: rgba(142, 207, 184, 0.45);
}
:root[data-theme="dark"] .ce-agent-messages {
  background: #101d1b;
}
:root[data-theme="dark"] .ce-agent-msg--assistant {
  background: #243633;
  border-color: rgba(214, 202, 188, 0.26);
  color: #f0ece3;
}
:root[data-theme="dark"] .ce-agent-msg--user {
  background: #195042;
  color: #f6f2e9;
}
:root[data-theme="dark"] .ce-agent-msg--error {
  background: rgba(127, 29, 29, 0.38);
  border-color: rgba(248, 113, 113, 0.45);
  color: #fecaca;
}
:root[data-theme="dark"] .ce-agent-thinking {
  background: rgba(25, 80, 66, 0.45);
  border-color: rgba(142, 207, 184, 0.32);
  color: #d7ebe3;
}
:root[data-theme="dark"] .ce-agent-input-wrap {
  background: #152724;
  border-top-color: rgba(214, 202, 188, 0.2);
}
:root[data-theme="dark"] .ce-agent-input {
  background: #1f312e;
  color: #efe9df;
  border-color: rgba(214, 202, 188, 0.24);
}
:root[data-theme="dark"] .ce-agent-input::placeholder {
  color: #aebbb3;
}
:root[data-theme="dark"] .ce-agent-input:focus {
  border-color: rgba(142, 207, 184, 0.52);
  box-shadow: 0 0 0 3px rgba(25, 80, 66, 0.35);
}
:root[data-theme="dark"] .ce-agent-icon-btn {
  background: #203330;
  color: #d3ddd7;
  border-color: rgba(214, 202, 188, 0.22);
}
:root[data-theme="dark"] .ce-agent-icon-btn:hover {
  background: #2a413c;
  color: #f1ece2;
  border-color: rgba(142, 207, 184, 0.4);
}
:root[data-theme="dark"] .ce-agent-send {
  background: #195042;
  color: #f5f0e7;
}
:root[data-theme="dark"] .ce-agent-send:hover:not(:disabled) {
  background: #236b56;
}
:root[data-theme="dark"] .ce-export-menu {
  background: var(--color-surface);
  border-color: var(--color-border);
}
:root[data-theme="dark"] .ce-export-menu-item {
  color: var(--color-text);
}
:root[data-theme="dark"] .computi-rel-shell {
  background: var(--color-surface);
  border-color: var(--color-border);
}
:root[data-theme="dark"] .computi-rel-chat,
:root[data-theme="dark"] .computi-rel-viewer {
  background: var(--color-bg);
  border-color: var(--color-border);
}
:root[data-theme="dark"] .computi-rel-viewer-content {
  background: var(--color-bg);
  border-color: var(--color-border);
}
:root[data-theme="dark"] .computi-rel-viewer-split {
  background: var(--color-surface);
  border-color: var(--color-border);
}
/* La "carta" della relazione resta cream in entrambi i temi: è un
   documento stampabile, non una superficie di chrome dell'app — vedi
   DESIGN.md. Nessuna inversione scura qui: la definizione unica vive
   accanto a .relazione-md-preview (paragrafo "pagina carta"). */
:root[data-theme="dark"] .computi-rel-edit-row {
  background: var(--color-bg);
}

/* ===========================================================================
   UX layer (non-invasive): toast + confirm modal
   =========================================================================== */

.ui-toast-root {
  position: fixed;
  top: 74px;
  right: 18px;
  z-index: 1400;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.ui-toast {
  pointer-events: auto;
  min-width: 280px;
  max-width: 420px;
  padding: 12px 14px;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  box-shadow: var(--shadow-2);
  background: var(--raised);
  color: var(--color-text);
  font-family: var(--font-sans);
  display: flex;
  gap: 10px;
  align-items: flex-start;
  animation: uiToastIn .25s var(--ease);
}

.ui-toast--success { border-color: rgba(25, 80, 66, 0.35); background: rgba(25, 80, 66, 0.08); }
.ui-toast--error { border-color: rgba(161, 69, 58, 0.35); background: rgba(161, 69, 58, 0.08); }
.ui-toast--info { border-color: rgba(145,133,90,.4); background: var(--surface); }

.ui-toast-icon {
  font-size: 14px;
  line-height: 1;
  margin-top: 2px;
}

.ui-toast-text {
  font-size: 13px;
  line-height: 1.5;
}

@keyframes uiToastIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.ui-confirm-overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(16, 32, 29, 0.55);
  backdrop-filter: blur(3px);
  z-index: 1500;
  padding: 16px;
}

.ui-confirm-overlay.is-open { display: flex; }

.ui-confirm-modal {
  width: min(100%, 440px);
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-2);
  padding: 20px 22px;
  animation: mq-rise .4s var(--ease) both;
}

.ui-confirm-title {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: 20px;
  letter-spacing: -0.01em;
  color: var(--color-text);
  margin-bottom: 8px;
}

.ui-confirm-message {
  font-family: var(--font-sans);
  font-size: 13.5px;
  color: var(--color-text-muted);
  line-height: 1.6;
  margin-bottom: 18px;
  /* Il messaggio arriva via textContent: senza questo gli a capo dei testi
     lunghi collassano in un blocco unico, illeggibile proprio dove la
     leggibilita' conta di piu' (spiegazioni prima di un consenso). */
  white-space: pre-line;
}

.ui-confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.ui-confirm-btn {
  border: 1px solid var(--hairline);
  background: var(--raised);
  color: var(--color-text);
  font-family: var(--font-sans);
  border-radius: var(--r-sm);
  min-height: 38px;
  font-size: 13px;
  font-weight: 600;
  padding: 0 15px;
  cursor: pointer;
  transition: border-color .15s, background .15s, box-shadow .15s;
}

.ui-confirm-btn--ghost:hover {
  border-color: var(--ink-3);
  box-shadow: var(--shadow-1);
}

/* Accettare dei documenti non e' un'azione distruttiva: il rosso mattone e'
   riservato a cio' che cancella. Qui vale l'emerald pieno del primario. */
.consensi-accetta {
  background: var(--primary);
  color: var(--primary-ink);
  border-color: var(--primary);
}
.consensi-accetta:hover { background: var(--primary-h); border-color: var(--primary-h); }

.ui-confirm-btn--danger {
  border-color: #a1453a;
  background: #a1453a;
  color: #fff;
}

.ui-confirm-btn--danger:hover {
  background: #8a3a30;
  border-color: #8a3a30;
}

:root[data-theme="dark"] .ui-toast {
  background: var(--color-surface);
  color: var(--color-text);
  border-color: var(--color-border);
}
:root[data-theme="dark"] .ui-toast--info {
  background: rgba(25, 80, 66, 0.2);
  border-color: rgba(90, 184, 154, 0.35);
}
:root[data-theme="dark"] .ui-confirm-modal {
  background: var(--color-surface);
  border-color: var(--color-border);
}
:root[data-theme="dark"] .ui-confirm-title {
  color: var(--color-text);
}
:root[data-theme="dark"] .ui-confirm-message {
  color: var(--color-text-muted);
}
:root[data-theme="dark"] .ui-confirm-btn {
  background: var(--color-surface);
  color: var(--color-text);
  border-color: var(--color-border);
}

:root[data-theme="dark"] .ui-confirm-btn--ghost:hover {
  background: rgba(25, 80, 66, 0.35);
  border-color: rgba(142, 207, 184, 0.35);
}

:root[data-theme="dark"] .ui-confirm-btn--danger:hover {
  background: #b0584c;
  border-color: #b0584c;
}

/* Dark theme — quality indicators (colors stay vivid on dark bg) */
:root[data-theme="dark"] .ce-quality-low  { color: #ffc53d; }
:root[data-theme="dark"] .ce-quality-warn { color: #ff8c42; }
:root[data-theme="dark"] .ce-quality-err  { color: #ff5252; }
:root[data-theme="dark"] .ce-quality-badge { background: #c62828; }
:root[data-theme="dark"] .ce-row-desc[data-quality="low_score"] td:first-child {
  border-left-color: #ffc53d;
}
:root[data-theme="dark"] .ce-row-desc[data-quality="um_mismatch"] td:first-child {
  border-left-color: #ff8c42;
}
:root[data-theme="dark"] .ce-row-desc[data-quality="not_found"] td:first-child {
  border-left-color: #ff5252;
}

/* =========================================================
   Account Modal & Prezziari Custom UI
   ========================================================= */

/* --- Overlay --- */
.account-modal-overlay,
.upload-wizard-overlay {
  position: fixed;
  inset: 0;
  z-index: 1100;
  background: rgba(16, 32, 29, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  backdrop-filter: blur(3px);
}
.upload-wizard-overlay { z-index: 1200; }

.account-modal-overlay[hidden],
.upload-wizard-overlay[hidden] { display: none; }

/* --- Panel --- */
.account-panel,
.upload-wizard-panel {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-2);
  width: 100%;
  max-width: 680px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: mq-rise .4s var(--ease) both;
}
.upload-wizard-panel { max-width: 520px; }

/* --- Modal header --- */
.account-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 0;
  flex-shrink: 0;
}
.account-title {
  font-family: var(--font-serif);
  font-size: 24px;
  font-weight: 400;
  letter-spacing: -0.01em;
  color: var(--color-text);
  margin: 0;
}
.account-close-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--ink-3);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.account-close-btn:hover {
  background: var(--hairline-2);
  color: var(--color-text);
}

/* --- Tabs --- */
.account-tabs {
  display: flex;
  gap: 4px;
  padding: 16px 24px 0;
  border-bottom: 1px solid var(--hairline);
  flex-shrink: 0;
}
.account-tab {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  padding: 8px 14px;
  font-family: var(--font-sans);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  border-radius: var(--r-sm) var(--r-sm) 0 0;
}
.account-tab:hover { color: var(--color-text); }
.account-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}
:root[data-theme="dark"] .account-tab.active { color: var(--accent-soft); border-bottom-color: var(--accent-soft); }

/* --- Tab content --- */
.account-tab-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px 24px;
  min-height: 0;
}
.account-tab-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.account-tab-section-title {
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-text);
}
.account-add-btn {
  background: var(--primary);
  color: var(--primary-ink);
  border: none;
  border-radius: var(--r-sm);
  min-height: 36px;
  padding: 0 14px;
  font-family: var(--font-sans);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s var(--ease), transform .2s var(--ease);
  white-space: nowrap;
}
.account-add-btn:hover { background: var(--primary-h); transform: translateY(-1px); }

/* --- Prezziari list --- */
.account-prezziari-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.account-prezziari-loading,
.account-prezziari-empty {
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.875rem;
  padding: 40px 0;
}
.account-prezziari-empty-icon {
  font-size: 2rem;
  margin-bottom: 10px;
}
.account-prezziari-empty p { margin: 4px 0; }
.account-prezziari-empty-cta {
  display: inline-block;
  margin-top: 12px;
  color: var(--color-primary);
  font-weight: 600;
  cursor: pointer;
  background: none;
  border: none;
  font-size: 0.875rem;
  font-family: var(--font-sans);
}
.account-prezziari-empty-cta:hover { text-decoration: underline; }

/* --- Prezziario card --- */
.prezziario-card {
  background: var(--raised);
  border: 1px solid var(--hairline);
  border-left: 3px solid var(--hairline);
  border-radius: var(--r-md);
  padding: 12px 16px;
  transition: box-shadow 0.15s, border-color .15s;
}
:root[data-theme="dark"] .prezziario-card { background: rgba(255,255,255,.03); }
.prezziario-card--ready   { border-left-color: var(--primary); }
.prezziario-card--processing { border-left-color: var(--brand-accent); }
.prezziario-card--error   { border-left-color: #a1453a; }

.prezziario-card-row1 {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}
.prezziario-card-name {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--ink);
  line-height: 1.3;
}
.prezziario-card-badge {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: .04em;
  font-weight: 500;
  border-radius: 20px;
  padding: 2px 10px;
  white-space: nowrap;
  flex-shrink: 0;
}
.prezziario-card-badge--ready {
  background: rgba(25, 80, 66, 0.12);
  color: var(--primary);
}
.prezziario-card-badge--processing {
  background: rgba(145, 133, 90, 0.14);
  color: var(--gold-ink);
}
.prezziario-card-badge--error {
  background: rgba(161, 69, 58, 0.12);
  color: #a1453a;
}

.prezziario-card-row2 {
  font-size: 0.78rem;
  color: var(--ink-2);
  margin-top: 4px;
}
.prezziario-card-row3 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  gap: 8px;
}
.prezziario-card-meta {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--ink-3);
}
.prezziario-card-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.prezziario-card-btn {
  font-size: 0.75rem;
  font-family: var(--font-sans);
  font-weight: 500;
  border-radius: var(--r-sm);
  padding: 4px 10px;
  border: 1px solid var(--hairline);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.prezziario-card-btn--use {
  background: rgba(25, 80, 66, 0.08);
  color: var(--primary);
  border-color: transparent;
}
.prezziario-card-btn--use:hover { background: var(--primary); color: var(--primary-ink); }
.prezziario-card-btn--delete {
  background: rgba(161, 69, 58, 0.08);
  color: #a1453a;
  border-color: transparent;
}
.prezziario-card-btn--delete:hover { background: #a1453a; color: #fff; }

/* Inline delete confirm */
.prezziario-card-confirm {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.prezziario-card-confirm-text {
  font-size: 0.75rem;
  color: #a1453a;
  font-weight: 500;
}

/* Progress bar in card */
.prezziario-card-progress-track {
  height: 6px;
  background: var(--hairline);
  border-radius: 99px;
  overflow: hidden;
  margin-top: 10px;
}
.prezziario-card-progress-fill {
  height: 100%;
  background: var(--brand-accent);
  border-radius: 99px;
  transition: width 0.4s ease;
}
.prezziario-card-progress-label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--ink-3);
  margin-top: 4px;
  text-align: right;
}

/* Error message in card */
.prezziario-card-error-msg {
  font-size: 0.78rem;
  color: #a1453a;
  margin-top: 4px;
}

/* --- Placeholder tabs --- */
.account-placeholder {
  text-align: center;
  padding: 60px 0;
  color: var(--ink-2);
}
.account-placeholder-icon { font-size: 2.2rem; margin-bottom: 12px; }
.account-placeholder p { font-size: 0.875rem; }

/* --- Gruppi di impostazioni ---
   Otto righe erano cresciute in una colonna piatta, senza alcun raggruppamento:
   con l'aggiunta della firma, dell'informativa e del promemoria era diventata
   una lista da leggere riga per riga invece che una mappa da scorrere. Un
   titolo per gruppo, in Zodiak come gli altri titoli di sezione/modale del
   prodotto (vedi «Account» qui sopra) — non piu' un'etichetta mono piccola,
   che si perdeva nella pagina invece di guidare l'occhio. Mai oro: quel
   gesto e' gia' impegnato altrove, e su quattro titoli diventerebbe rumore
   invece che accento. */
.impostazione-gruppo + .impostazione-gruppo {
  margin-top: 30px;
}
.impostazione-categoria {
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 400;
  letter-spacing: -0.005em;
  text-transform: none;
  color: var(--color-text);
  margin-bottom: 4px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--color-border);
}

/* --- Righe di impostazione --- */
.impostazione-riga {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 16px 0;
  border-bottom: 1px solid var(--color-border);
}
.impostazione-riga:last-child { border-bottom: none; }

.impostazione-testo {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.impostazione-titolo {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-text);
}
.impostazione-nota {
  font-size: 0.8rem;
  line-height: 1.45;
  color: var(--color-text-muted);
}

/* Invito a installare l'assistente per la scrivania. Sta sotto la riga e non
   dentro, perche' compare solo in una condizione: un interruttore grigio dice
   che qualcosa manca, non cosa fare. */
.impostazione-azione {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  margin: -4px 0 16px;
  padding: 14px 16px;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  background: var(--color-surface-2, rgba(127, 127, 127, 0.06));
}
.impostazione-azione[hidden] { display: none; }

.impostazione-azione-bottoni {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* Questa classe veste sia <a> sia <button>, e le due cose non partono uguali:
   il browser da' al link la manina e il carattere della pagina, al bottone la
   freccia e un carattere di sistema. Senza le tre righe qui sotto il bottone
   "Prova l'avviso" sembrava disattivato — cliccarlo funzionava, ma nessuno ci
   provava, ed e' cosi' che e' stato segnalato come rotto. */
.impostazione-azione-btn {
  display: inline-block;
  padding: 8px 16px;
  border: none;
  border-radius: 8px;
  background: var(--color-accent, #195042);
  color: #fff;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: filter 160ms ease;
}
.impostazione-azione-btn:hover { filter: brightness(1.08); }
.impostazione-azione-btn[hidden] { display: none; }

/* Il secondario e' l'alternativa, non l'azione principale: chi ha gia' il
   programma deve poter distinguere a colpo d'occhio "avvia" da "scarica". */
.impostazione-azione-btn--secondario {
  background: transparent;
  color: var(--color-text);
  border: 1px solid var(--color-border);
}
.impostazione-azione-btn:focus-visible {
  outline: 2px solid var(--color-accent, #195042);
  outline-offset: 2px;
}

.impostazione-azione-nota {
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--color-text-muted);
}

/* Interruttore. Costruito su una checkbox vera invece che su un div: cosi'
   funziona da tastiera, lo annunciano i lettori di schermo e lo stato
   disabilitato e' quello nativo, senza doverlo simulare. */
.interruttore {
  position: relative;
  flex: 0 0 auto;
  width: 42px;
  height: 24px;
  cursor: pointer;
}
.interruttore input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
}
.interruttore input:disabled { cursor: not-allowed; }

.interruttore-cursore {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: var(--color-border);
  transition: background 160ms ease;
  pointer-events: none;
}
.interruttore-cursore::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.28);
  transition: transform 160ms ease;
}
.interruttore input:checked + .interruttore-cursore {
  background: var(--primary, #226753);
}
.interruttore input:checked + .interruttore-cursore::before {
  transform: translateX(18px);
}
.interruttore input:disabled + .interruttore-cursore { opacity: 0.45; }
.interruttore input:focus-visible + .interruttore-cursore {
  outline: 2px solid var(--primary, #226753);
  outline-offset: 2px;
}

/* --- Wizard stepper --- */
.wizard-stepper {
  display: flex;
  align-items: center;
  padding: 20px 32px 0;
  flex-shrink: 0;
}
.wizard-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.wizard-step-circle {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--color-border);
  color: var(--color-text-muted);
  font-size: 0.8rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s;
}
.wizard-step.active .wizard-step-circle {
  background: var(--primary);
  color: var(--primary-ink);
}
.wizard-step.done .wizard-step-circle {
  background: rgba(25, 80, 66, 0.14);
  color: var(--primary);
}
.wizard-step-label {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--ink-3);
  transition: color 0.2s;
}
.wizard-step.active .wizard-step-label { color: var(--primary); font-weight: 600; }
.wizard-step.done .wizard-step-label { color: var(--ink-2); }
.wizard-step-line {
  flex: 1;
  height: 2px;
  background: var(--hairline);
  margin: 0 4px;
  margin-bottom: 18px;
  transition: background 0.2s;
}

/* --- Wizard step content --- */
.wizard-step-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
}
.wizard-step-content[hidden] { display: none; }

.wizard-field-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.wizard-field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.wizard-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink);
}
.wizard-required { color: #a1453a; }
.wizard-input {
  padding: 8px 12px;
  min-height: var(--ctl-h);
  border: 1px solid var(--hairline);
  border-radius: var(--r-sm);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  color: var(--ink);
  background: var(--raised);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.wizard-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--focus);
}

/* --- Wizard dropzone --- */
.wizard-dropzone {
  border: 2px dashed var(--hairline);
  border-radius: var(--r-md);
  padding: 32px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.wizard-dropzone:hover,
.wizard-dropzone:focus,
.wizard-dropzone.dragover {
  border-color: var(--primary);
  background: rgba(25, 80, 66, 0.06);
  outline: none;
}
.wizard-dropzone-icon { font-size: 2rem; }
.wizard-dropzone-text { font-weight: 600; color: var(--ink); font-size: 0.9rem; }
.wizard-dropzone-sub { font-size: 0.8rem; color: var(--ink-2); }
.wizard-dropzone-link { color: var(--primary); text-decoration: underline; cursor: pointer; }
.wizard-dropzone-info { font-size: 0.75rem; color: var(--ink-3); margin-top: 4px; }

.wizard-file-selected {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(25, 80, 66, 0.06);
  border: 1px solid var(--primary);
  border-radius: var(--r-sm);
  padding: 10px 14px;
}
.wizard-file-selected[hidden] { display: none; }
.wizard-file-icon { font-size: 1.3rem; flex-shrink: 0; }
.wizard-file-info { flex: 1; min-width: 0; }
.wizard-file-name {
  display: block;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wizard-file-size { display: block; font-family: var(--font-mono); font-size: 0.75rem; color: var(--ink-3); }
.wizard-file-remove {
  background: none;
  border: none;
  color: var(--ink-3);
  font-size: 1.2rem;
  cursor: pointer;
  flex-shrink: 0;
  border-radius: var(--r-sm);
  padding: 2px 4px;
  line-height: 1;
}
.wizard-file-remove:hover { color: #a1453a; }

.wizard-field-error {
  font-size: 0.8rem;
  color: #a1453a;
  background: rgba(161, 69, 58, 0.08);
  border-radius: var(--r-sm);
  padding: 6px 10px;
}
.wizard-field-error[hidden] { display: none; }

/* --- Wizard actions --- */
.wizard-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px 0 20px;
  flex-shrink: 0;
}
.wizard-actions--centered { justify-content: center; }
.wizard-btn {
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 600;
  min-height: var(--ctl-h);
  border-radius: var(--r-sm);
  padding: 0 20px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background .2s var(--ease), transform .2s var(--ease), box-shadow .25s var(--ease), opacity .15s;
}
.wizard-btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; box-shadow: none; }
.wizard-btn--primary {
  background: var(--primary);
  color: var(--primary-ink);
}
.wizard-btn--primary:not(:disabled):hover { background: var(--primary-h); transform: translateY(-1px); box-shadow: var(--shadow-2); }
.wizard-btn--ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--hairline);
}
.wizard-btn--ghost:hover { border-color: var(--ink-3); background: var(--surface); }

/* --- Wizard step 3 views --- */
.wizard-processing-view,
.wizard-success-view,
.wizard-error-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  padding: 16px 0;
}
.wizard-processing-view[hidden],
.wizard-success-view[hidden],
.wizard-error-view[hidden] { display: none; }

.wizard-processing-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--hairline);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: wizard-spin 0.8s linear infinite;
  margin-bottom: 8px;
}
@keyframes wizard-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .wizard-processing-spinner { animation: none; border-top-color: var(--hairline); }
}

.wizard-processing-title,
.wizard-success-title,
.wizard-error-title {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: 20px;
  color: var(--ink);
}
.wizard-processing-note,
.wizard-success-note,
.wizard-error-note {
  font-size: 0.83rem;
  color: var(--ink-2);
  max-width: 360px;
  line-height: 1.5;
}
.wizard-success-icon,
.wizard-error-icon {
  font-size: 2.4rem;
  margin-bottom: 4px;
}

.wizard-progress-wrap { width: 100%; max-width: 320px; margin-top: 12px; }
.wizard-progress-bar-track {
  height: 6px;
  background: var(--hairline);
  border-radius: 99px;
  overflow: hidden;
}
.wizard-progress-bar {
  height: 100%;
  background: var(--primary);
  border-radius: 99px;
  transition: width 0.5s ease;
}
.wizard-progress-label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--ink-3);
  text-align: right;
  margin-top: 4px;
}

/* --- Highlight "Usa nel computo" --- */
@keyframes ce-prez-highlight-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(25, 80, 66, 0.5); background: rgba(25, 80, 66, 0.10); }
  50%  { box-shadow: 0 0 0 6px rgba(25, 80, 66, 0); background: rgba(25, 80, 66, 0.10); }
  100% { box-shadow: 0 0 0 0 rgba(25, 80, 66, 0); background: transparent; }
}
.ce-prezziario-highlight {
  animation: ce-prez-highlight-pulse 0.7s ease 3;
  border-radius: var(--r-sm);
}

/* --- Dark mode overrides --- */
:root[data-theme="dark"] .account-panel,
:root[data-theme="dark"] .upload-wizard-panel {
  background: var(--color-surface);
  box-shadow: var(--shadow-md), 0 0 0 1px var(--color-border);
}
/* =========================================================================
   V2 FOUNDATION — componenti base del redesign (DESIGN.md)
   Ogni fase successiva costruisce su queste classi; nessun selettore qui
   tocca l'editor del computo.
   ========================================================================= */

.mq-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  min-height: var(--ctl-h);
  font-family: var(--font-sans); font-size: 14.5px; font-weight: 600;
  border-radius: var(--r-sm); border: 1px solid transparent;
  padding: 0 20px; cursor: pointer; text-decoration: none;
  color: var(--ink);
  transition: background .2s var(--ease), color .2s var(--ease),
              border-color .2s var(--ease), transform .2s var(--ease),
              box-shadow .25s var(--ease);
}
.mq-btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.mq-btn:active { transform: translateY(0.5px); }
.mq-btn--primary { background: var(--primary); color: var(--primary-ink); }
.mq-btn--primary:hover { background: var(--primary-h); transform: translateY(-1px); box-shadow: var(--shadow-2); }
.mq-btn--primary:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: none; }
.mq-btn--ghost { background: transparent; color: var(--ink); border-color: var(--hairline); }
.mq-btn--ghost:hover { border-color: var(--ink-3); background: var(--surface); }
.mq-btn--sm { min-height: 36px; padding: 0 14px; font-size: 13px; }

.mq-field { display: flex; flex-direction: column; gap: 7px; }
.mq-field > label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); letter-spacing: .01em; }
.mq-input-wrap { position: relative; display: flex; align-items: center; }
.mq-input-wrap svg.mq-lead { position: absolute; left: 13px; color: var(--ink-3); pointer-events: none; }
.mq-input {
  width: 100%; min-height: var(--ctl-h);
  font-family: var(--font-sans); font-size: 14.5px; color: var(--ink);
  background: var(--raised); border: 1px solid var(--hairline);
  border-radius: var(--r-sm); padding: 10px 13px;
  transition: border-color .2s, box-shadow .2s, background .2s;
}
.mq-input-wrap svg.mq-lead ~ .mq-input { padding-left: 40px; }
.mq-input::placeholder { color: var(--ink-3); }
.mq-input:hover { border-color: var(--ink-3); }
.mq-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--focus); }
:root[data-theme="dark"] .mq-input { background: rgba(255,255,255,.04); }
.mq-textarea { min-height: 72px; resize: vertical; line-height: 1.55; font-size: 13.5px; }

.mq-mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

.mq-kicker {
  font-family: var(--font-mono); font-size: 10.5px; font-weight: 500;
  letter-spacing: .16em; text-transform: uppercase; color: var(--ink-3);
}

.mq-row-btn {
  display: flex; align-items: center; gap: 12px; width: 100%;
  min-height: var(--ctl-h); padding: 8px 14px;
  font-family: var(--font-sans); font-size: 13.5px; font-weight: 500; color: var(--ink);
  background: var(--raised); border: 1px solid var(--hairline); border-radius: var(--r-sm);
  cursor: pointer; text-align: left;
  transition: border-color .2s, background .2s, box-shadow .2s;
}
:root[data-theme="dark"] .mq-row-btn { background: rgba(255,255,255,.03); }
.mq-row-btn:hover { border-color: var(--ink-3); box-shadow: var(--shadow-1); }
.mq-row-btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.mq-row-btn .rb-icon { color: var(--ink-3); flex-shrink: 0; }
.mq-row-btn .rb-body { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.mq-row-btn .rb-sub { font-size: 11.5px; font-weight: 400; color: var(--ink-3); }
.mq-row-btn .rb-chev { color: var(--ink-3); flex-shrink: 0; transition: transform .2s var(--ease); }
.mq-row-btn:hover .rb-chev { transform: translateX(3px); }

.mq-seg {
  position: relative; display: grid; grid-template-columns: 1fr 1fr;
  background: var(--bg); border: 1px solid var(--hairline);
  border-radius: 11px; padding: 4px; min-height: var(--ctl-h);
}
.mq-seg .mq-seg-thumb {
  position: absolute; top: 4px; bottom: 4px; left: 4px; width: calc(50% - 4px);
  background: var(--raised); border-radius: 8px; box-shadow: var(--shadow-1);
  transition: transform .3s var(--ease);
}
:root[data-theme="dark"] .mq-seg .mq-seg-thumb { background: var(--primary); }
.mq-seg[data-active="1"] .mq-seg-thumb { transform: translateX(100%); }
.mq-seg > button {
  position: relative; z-index: 1;
  font-family: var(--font-sans); font-size: 13.5px; font-weight: 600;
  color: var(--ink-2); background: none; border: none;
  cursor: pointer; border-radius: 8px; transition: color .2s;
}
.mq-seg > button.active, .mq-seg > button[aria-pressed="true"] { color: var(--ink); }
:root[data-theme="dark"] .mq-seg > button.active,
:root[data-theme="dark"] .mq-seg > button[aria-pressed="true"] { color: var(--primary-ink); }
.mq-seg > button:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }

.mq-check-row {
  display: flex; align-items: center; gap: 12px; min-height: var(--ctl-h);
  padding: 6px 13px; border: 1px solid var(--hairline); border-radius: var(--r-sm);
  background: var(--raised); cursor: pointer;
  transition: border-color .2s, background .2s;
}
:root[data-theme="dark"] .mq-check-row { background: rgba(255,255,255,.03); }
.mq-check-row:hover { border-color: var(--ink-3); }
.mq-check-row[data-on="true"] { border-color: rgba(25,80,66,.55); background: rgba(25,80,66,.05); }
:root[data-theme="dark"] .mq-check-row[data-on="true"] { border-color: rgba(142,207,184,.4); background: rgba(142,207,184,.05); }
.mq-check {
  width: 18px; height: 18px; border-radius: 5px; flex-shrink: 0;
  border: 1.5px solid var(--ink-3); display: grid; place-items: center;
  transition: background .2s var(--ease), border-color .2s;
}
.mq-check-row[data-on="true"] .mq-check { background: var(--primary); border-color: var(--primary); }
.mq-check svg { color: #fff; opacity: 0; transform: scale(.5); transition: opacity .2s, transform .25s var(--ease); }
.mq-check-row[data-on="true"] .mq-check svg { opacity: 1; transform: scale(1); }
.mq-check-row .cr-body { flex: 1; min-width: 0; line-height: 1.35; }
.mq-check-row .cr-name { font-size: 13.5px; font-weight: 600; display: block; }
.mq-check-row .cr-sub { font-size: 11.5px; color: var(--ink-3); display: block; }
.mq-tag {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: .1em;
  color: var(--gold-ink); border: 1px solid rgba(145,133,90,.35);
  padding: 2.5px 8px; border-radius: 999px; text-transform: uppercase; flex-shrink: 0;
}

/* Modale base v2 */
.mq-modal { position: fixed; inset: 0; z-index: 900; display: none; align-items: center; justify-content: center; padding: 24px; }
.mq-modal.open { display: flex; }
.mq-modal__backdrop { position: absolute; inset: 0; background: rgba(16, 32, 29, 0.55); backdrop-filter: blur(3px); }
.mq-modal__panel {
  position: relative; width: min(560px, 100%); max-height: 88vh;
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: var(--r-lg); box-shadow: var(--shadow-2);
  animation: mq-rise .45s var(--ease) both;
}
.mq-modal__head { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px 0; }
.mq-modal__head h3 { font-family: var(--font-serif); font-weight: 400; font-size: 24px; letter-spacing: -0.01em; margin: 0; }
.mq-modal__close {
  background: none; border: none; color: var(--ink-3); cursor: pointer;
  font-size: 22px; line-height: 1; padding: 6px 9px; border-radius: 8px;
  transition: color .15s, background .15s;
}
.mq-modal__close:hover { color: var(--ink); background: var(--hairline-2); }
.mq-modal__help { padding: 8px 24px 0; font-size: 13px; color: var(--ink-2); line-height: 1.6; max-width: 62ch; }
.mq-modal__body { padding: 18px 24px; overflow: auto; }
.mq-modal__foot { display: flex; justify-content: flex-end; align-items: center; gap: 12px; padding: 14px 24px 20px; border-top: 1px solid var(--hairline-2); }

/* Firma: carta millimetrata — SOLO superfici di lavoro/misura */
.paper-grid {
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px),
    linear-gradient(rgba(145,133,90,.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(145,133,90,.07) 1px, transparent 1px);
  background-size: 8px 8px, 8px 8px, 40px 40px, 40px 40px;
}

/* Momento orchestrato unico per schermata */
@keyframes mq-rise {
  from { opacity: 0; transform: translateY(14px); filter: blur(5px); }
  to   { opacity: 1; transform: translateY(0);   filter: blur(0); }
}
.mq-rise { animation: mq-rise .7s var(--ease) both; animation-delay: calc(var(--i, 0) * 90ms); }

/* Ingresso leggero per liste con più elementi simultanei (es. righe macro
   durante la generazione): stessa cadenza di mq-rise ma senza filter:blur,
   costoso da animare ripetuto su molti elementi contemporaneamente. */
@keyframes mq-rise-list {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.mq-rise-list { animation: mq-rise-list .4s var(--ease) both; animation-delay: calc(var(--i, 0) * 60ms); }


/* ══════════════════════════════════════════════════════════════════
   DATI PROFESSIONALI — la griglia dei cinque campi
   ══════════════════════════════════════════════════════════════════
   Due colonne su desktop, una su telefono. I due campi corti — numero di
   iscrizione e partita IVA — stanno affiancati perche' sono brevi e perche'
   si compilano insieme guardando lo stesso tesserino: separarli su due righe
   allungherebbe il modulo senza rendere piu' chiaro niente. */
.profilo-campi,
.imp-campi {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-block-end: 4px;
  /* Il contenitore .impostazione-azione e' flex: senza questo la griglia si
     restringe al contenuto invece di riempire, e i campi finivano a 376px su
     615 disponibili — misurato, non supposto. */
  width: 100%;
  align-self: stretch;
}
.profilo-campo,
.imp-campo { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 5px; }
.profilo-campo--corto { grid-column: auto; }

.profilo-campo > span,
.imp-campo > span {
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .02em;
  color: var(--color-text-mut);
}
.profilo-campo > input,
.imp-campo > input {
  padding: 8px 12px;
  min-height: var(--ctl-h);
  border: 1px solid var(--hairline);
  border-radius: var(--r-sm);
  font-family: var(--font-sans);
  font-size: .875rem;
  color: var(--ink);
  background: var(--raised);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.profilo-campo > input:focus,
.imp-campo > input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--focus);
}

/* Su telefono i due corti tornano a piena larghezza: affiancati a 390px
   diventano due caselle da centrare col pollice, e un numero di iscrizione
   sbagliato finisce firmato su una relazione. */
@media (max-width: 40rem) {
  .profilo-campi,
  .imp-campi { grid-template-columns: minmax(0, 1fr); }
  .profilo-campo--corto { grid-column: 1 / -1; }
}

/* ══════════════════════════════════════════════════════════════════
   CANCELLAZIONE DELL'ACCOUNT — la variante distruttiva
   ══════════════════════════════════════════════════════════════════
   Riusa la grammatica di .impostazione-*: e' una riga di impostazioni come
   le altre, non un'isola con regole sue. Cambia solo l'inchiostro.

   Il rosso mattone e' #a1453a, l'unico semantico caldo ammesso da DESIGN.md e
   quello gia' usato altrove per le conferme distruttive. Il pannello NON usa
   uno sfondo rosso pieno: un blocco allarmante mette in guardia dal leggerlo,
   e qui c'e' scritto esattamente cosa si perde. La cornice basta a dire
   «attenzione» lasciando leggibile cio' che conta. */
.impostazione-riga--pericolo .impostazione-titolo { color: #a1453a; }

.impostazione-azione-btn--pericolo {
  background: #a1453a;
  color: #fff;
}
.impostazione-azione-btn--pericolo:disabled {
  /* Disabilitato finche' l'email non combacia: il pulsante c'e' e si vede,
     ma non si accende. Nasconderlo lascerebbe l'utente a chiedersi dove sia. */
  opacity: .45;
  cursor: not-allowed;
  filter: none;
}
.impostazione-azione-btn--pericolo:focus-visible { outline-color: #a1453a; }

.impostazione-azione--pericolo {
  border: 1px solid rgba(161, 69, 58, .35);
  border-radius: 10px;
  padding: 16px;
  margin-block-start: 8px;
}

.account-elimina-titolo {
  margin: 0 0 4px;
  font-size: .8rem;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--color-text-mut);
}
.account-elimina-titolo:not(:first-child) { margin-block-start: 16px; }

.account-elimina-resta {
  margin: 0;
  padding-inline-start: 18px;
  font-size: .82rem;
  line-height: 1.5;
  color: var(--color-text-mut);
}

.account-elimina-campo {
  display: block;
  margin-block: 16px 6px;
  font-size: .85rem;
  color: var(--color-text);
}
/* Il campo eredita la grammatica dei form dell'app (vedi .wizard-input) e non
   la classe `.input` di DESIGN.md: quel nome esiste nei fogli della landing ma
   NON in questo, quindi scriverlo qui lasciava un input di sistema non
   stilizzato in mezzo a un'azione irreversibile. Verificato in browser. */
#account-elimina-conferma {
  width: 100%;
  max-width: 320px;
  padding: 8px 12px;
  min-height: var(--ctl-h);
  border: 1px solid var(--hairline);
  border-radius: var(--r-sm);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  color: var(--ink);
  background: var(--raised);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
/* Il focus e' rosso e non smeraldo: qui il campo non e' un passaggio di un
   modulo, e' l'ultimo diaframma prima di un'azione che non si annulla. */
#account-elimina-conferma:focus {
  border-color: #a1453a;
  box-shadow: 0 0 0 3px rgba(161, 69, 58, .22);
}
#account-elimina-pannello .impostazione-azione-bottoni { margin-block-start: 14px; }

/* Sotto i 40rem i due pulsanti stanno in colonna e a piena larghezza: uno
   accanto all'altro, «Elimina definitivamente» finirebbe stretto e tagliato,
   ed e' l'ultimo posto dove si vuole un controllo difficile da centrare. */
@media (max-width: 40rem) {
  #account-elimina-pannello .impostazione-azione-bottoni {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }
  #account-elimina-pannello .impostazione-azione-btn { width: 100%; }
  #account-elimina-conferma { max-width: none; }
}
