/* ============================================================
   Intact-Tooth AI Engine — Foglio di stile principale
   Tema Slate — chiaro/freddo professionale
   ============================================================ */

/* ===== RESET E VARIABILI ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

:root {
  /* Palette Slate */
  --bg-deep:        #eef0f5;
  --bg-card:        #f5f6fa;
  --bg-card-hover:  #eaecf3;
  --bg-elevated:    #ffffff;
  --accent:         #0d4a88;
  --accent-light:   #dcedf8;
  --accent-dark:    #0a3a6e;
  --accent-glow:    rgba(13, 74, 136, 0.12);
  --text-primary:   #1a1f2e;
  --text-secondary: #4a5068;
  --text-muted:     #7a839a;
  --danger:         #8b1a1a;
  --danger-light:   #fde8e8;
  --success:        #1a5c38;
  --success-light:  #d0eadc;
  --warning:        #7a4200;
  --warning-light:  #fde9c4;
  --border:         #c8cfe0;
  --border-strong:  #a8b4cc;

  /* Tipografia */
  --font: system-ui, 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;

  /* Spaziatura */
  --gap-sm:  8px;
  --gap-md:  16px;
  --gap-lg:  24px;
  --gap-xl:  40px;

  /* Bordi */
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;

  /* Transizioni */
  --transition: 0.25s ease;
  --transition-screen: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== BODY E HTML ===== */
html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font);
  background-color: var(--bg-deep);
  color: var(--text-primary);
  font-size: 16px;
  line-height: 1.7;
}

/* ===== SISTEMA SCHERMATE (SPA) ===== */
.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-deep);
  transform: translateX(100%);
  opacity: 0;
  pointer-events: none;
  transition:
    transform var(--transition-screen),
    opacity var(--transition-screen);
  overflow: hidden;
}

.screen.active {
  transform: translateX(0);
  opacity: 1;
  pointer-events: all;
}

.screen.slide-out {
  transform: translateX(-30%);
  opacity: 0;
  pointer-events: none;
}

/* ===== HEADER ===== */
.app-header {
  display: flex;
  align-items: center;
  padding: 12px var(--gap-md);
  background: rgba(245, 246, 250, 0.96);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  min-height: 56px;
  flex-shrink: 0;
  position: relative;
  z-index: 10;
}

.header-title {
  flex: 1;
  text-align: center;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: 0.03em;
}

.header-spacer {
  width: 40px;
}

/* ===== PULSANTE BACK ===== */
.btn-back {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: none;
  background: rgba(13, 74, 136, 0.07);
  border-radius: 50%;
  cursor: pointer;
  color: var(--accent);
  font-size: 1.2rem;
  transition: background var(--transition), transform var(--transition);
  flex-shrink: 0;
}

.btn-back:active {
  background: rgba(13, 74, 136, 0.16);
  transform: scale(0.92);
}

/* ===== CONTENUTO SCROLLABILE ===== */
.screen-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--gap-lg) var(--gap-md);
  -webkit-overflow-scrolling: touch;
}

/* ===== BOTTONI BASE ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--gap-sm);
  padding: 14px 28px;
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition:
    background var(--transition),
    transform var(--transition),
    box-shadow var(--transition),
    opacity var(--transition);
  text-transform: uppercase;
  user-select: none;
}

.btn:active {
  transform: scale(0.96);
}

.btn:disabled {
  opacity: 0.38;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  color: #ffffff;
  box-shadow: 0 4px 16px rgba(13, 74, 136, 0.28);
}

.btn-primary:not(:disabled):hover {
  box-shadow: 0 6px 22px rgba(13, 74, 136, 0.38);
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--accent);
  border: 1px solid var(--border-strong);
}

.btn-secondary:not(:disabled):hover {
  background: var(--accent-light);
  border-color: var(--accent);
}

.btn-accent {
  background: var(--accent);
  color: #ffffff;
  box-shadow: 0 4px 16px rgba(13, 74, 136, 0.28);
  font-size: 1rem;
}

.btn-accent:not(:disabled):hover {
  background: var(--accent-dark);
  box-shadow: 0 6px 22px rgba(13, 74, 136, 0.38);
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: none;
  padding: 4px 8px;
  font-size: 1rem;
  border-radius: var(--radius-sm);
}

.btn-danger:hover {
  background: var(--danger-light);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  background: var(--bg-card-hover);
}

/* Modificatori dimensione */
.btn-large {
  padding: 18px 48px;
  font-size: 1.1rem;
  border-radius: var(--radius-lg);
  letter-spacing: 0.1em;
}

.btn-small {
  padding: 8px 18px;
  font-size: 0.82rem;
  border-radius: var(--radius-sm);
}

.btn-full {
  width: 100%;
  margin-top: var(--gap-lg);
}

/* ===== SPLASH SCREEN ===== */
.splash-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: var(--gap-xl) var(--gap-lg);
  gap: var(--gap-lg);
  background: linear-gradient(160deg, #ffffff 0%, var(--bg-deep) 100%);
}

.logo-container {
  text-align: center;
  margin-bottom: var(--gap-lg);
}

.logo-icon {
  font-size: 4rem;
  margin-bottom: var(--gap-md);
  filter: drop-shadow(0 0 12px rgba(13, 74, 136, 0.35));
  animation: pulse-glow 3s ease-in-out infinite;
}

@keyframes pulse-glow {
  0%, 100% { filter: drop-shadow(0 0 8px rgba(13, 74, 136, 0.25)); }
  50%       { filter: drop-shadow(0 0 20px rgba(13, 74, 136, 0.55)); }
}

.logo-text {
  font-size: 2.2rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.logo-accent {
  color: var(--accent);
}

.logo-subtitle {
  margin-top: var(--gap-sm);
  font-size: 0.88rem;
  color: var(--text-secondary);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.version-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: var(--gap-sm);
}

/* ===== LISTA PAZIENTI ===== */
.patient-list {
  display: flex;
  flex-direction: column;
  gap: var(--gap-sm);
}

.patient-item {
  display: flex;
  align-items: center;
  gap: var(--gap-md);
  padding: var(--gap-md);
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
  transition:
    background var(--transition),
    border-color var(--transition),
    box-shadow var(--transition),
    transform var(--transition);
  text-align: left;
  width: 100%;
}

.patient-item:hover,
.patient-item:focus-visible {
  background: var(--accent-light);
  border-color: var(--accent);
  box-shadow: 0 4px 14px var(--accent-glow);
  outline: none;
}

.patient-item:active {
  transform: scale(0.98);
}

.patient-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-light), #c8dff4);
  border: 1px solid var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.patient-info {
  flex: 1;
  min-width: 0;
}

.patient-nome {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.patient-cod-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}

.patient-cod-label {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.patient-cod-value {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent);
  font-family: 'Courier New', monospace;
  background: var(--accent-light);
  padding: 1px 7px;
  border-radius: 4px;
  letter-spacing: 0.05em;
}

.patient-chevron {
  color: var(--text-muted);
  font-size: 1.1rem;
  flex-shrink: 0;
}

/* ===== CARD PAZIENTE ===== */
.patient-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--gap-xl) var(--gap-lg);
  text-align: center;
  margin-bottom: var(--gap-lg);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.patient-card-icon {
  font-size: 3.5rem;
  margin-bottom: var(--gap-md);
  line-height: 1;
}

.patient-card-name {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--gap-lg);
}

.patient-card-detail {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: var(--gap-sm) 0;
}

.detail-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.detail-value {
  font-size: 1.1rem;
  font-weight: 700;
  font-family: 'Courier New', monospace;
  letter-spacing: 0.1em;
  color: var(--text-primary);
}

.detail-value.accent {
  color: var(--accent);
}

/* ===== INFO ROWS ===== */
.info-rows {
  width: 100%;
  margin-top: var(--gap-md);
  padding-top: var(--gap-sm);
  border-top: 1px solid var(--border);
  text-align: left;
}

.info-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 7px 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.info-row:last-child {
  border-bottom: none;
}

.info-label {
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  min-width: 140px;
  flex-shrink: 0;
}

.info-value {
  color: var(--accent);
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.info-value a {
  color: var(--accent);
  text-decoration: none;
}

.info-value a:hover {
  color: var(--accent-dark);
  text-decoration: underline;
}

/* ===== SCHERMATA VALUTAZIONE ===== */
.val-patient-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px var(--gap-md);
  margin-bottom: var(--gap-lg);
}

.val-patient-name {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-primary);
}

.val-patient-cod {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent);
  font-family: 'Courier New', monospace;
  background: var(--accent-light);
  padding: 2px 8px;
  border-radius: 4px;
}

/* Sezione card con titolo */
.section-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--gap-md);
  margin-bottom: var(--gap-md);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
}

.section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: var(--gap-sm);
}

.section-hint {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: var(--gap-md);
}

/* Pulsanti fotocamera / libreria */
.foto-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--gap-sm);
}

/* ===== GRIGLIA PREVIEW FOTO ===== */
.preview-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--gap-sm);
  margin-bottom: var(--gap-sm);
}

.preview-item {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  aspect-ratio: 1 / 1;
}

.preview-img-wrapper {
  width: 100%;
  height: calc(100% - 38px);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #dde1eb;
}

.preview-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

/* Barra controlli sotto ogni anteprima */
.preview-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 8px;
  background: rgba(0, 0, 0, 0.26);
  height: 38px;
}

.btn-rotate {
  background: rgba(13, 74, 136, 0.1);
  border: 1px solid var(--border-strong);
  color: var(--accent);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 1rem;
  cursor: pointer;
  transition: background var(--transition);
  line-height: 1;
}

.btn-rotate:active {
  background: rgba(13, 74, 136, 0.22);
}

.rotation-badge {
  font-size: 0.65rem;
  color: var(--text-secondary);
}

.btn-remove {
  background: rgba(139, 26, 26, 0.08);
  border: 1px solid rgba(139, 26, 26, 0.28);
  color: var(--danger);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background var(--transition);
}

.btn-remove:active {
  background: rgba(139, 26, 26, 0.18);
}

/* Contatore foto */
.foto-counter {
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-bottom: var(--gap-sm);
}

/* ===== SPINNER ===== */
.spinner-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--gap-md);
  padding: var(--gap-lg);
  color: var(--text-secondary);
  font-size: 0.92rem;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(13, 74, 136, 0.15);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ===== MESSAGGI RISULTATO ===== */
.upload-result {
  margin-top: var(--gap-md);
  padding: var(--gap-md);
  border-radius: var(--radius-md);
  text-align: center;
  font-size: 0.95rem;
  font-weight: 500;
}

.upload-result.success {
  background: var(--success-light);
  border: 1px solid rgba(26, 92, 56, 0.28);
  color: var(--success);
}

.upload-result.error {
  background: var(--danger-light);
  border: 1px solid rgba(139, 26, 26, 0.28);
  color: var(--danger);
}

.upload-result .result-icon {
  font-size: 2rem;
  display: block;
  margin-bottom: var(--gap-sm);
}

/* ===== UTILITY ===== */
.hidden {
  display: none !important;
}

/* Scrollbar personalizzata (webkit) */
.screen-content::-webkit-scrollbar {
  width: 4px;
}

.screen-content::-webkit-scrollbar-track {
  background: transparent;
}

.screen-content::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 2px;
}

/* ===== SAFE AREA (iPhone con notch/isola) ===== */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .screen-content {
    padding-bottom: calc(var(--gap-lg) + env(safe-area-inset-bottom));
  }
  .app-header {
    padding-top: calc(12px + env(safe-area-inset-top));
  }
}

@supports (padding-top: env(safe-area-inset-top)) {
  #screen-splash {
    padding-top: env(safe-area-inset-top);
  }
}

/* ===== BANNER INSTALLAZIONE PWA ===== */
.install-banner {
  position: fixed;
  bottom: -300px;
  left: 0;
  right: 0;
  z-index: 9999;
  background: rgba(245, 246, 250, 0.98);
  border-top: 1.5px solid var(--border);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.09);
  padding: 14px 16px 20px;
  transition: bottom 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.install-banner.visible {
  bottom: 0;
}

/* ── Header banner iOS ── */
.install-banner-header {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.install-banner-app-icon {
  width: 44px;
  height: 44px;
  background: var(--bg-elevated);
  border: 1.5px solid var(--border-strong);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.install-banner-app-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.install-banner-app-info strong {
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
  display: block;
}

.install-banner-app-info span {
  color: var(--text-muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  display: block;
}

.install-banner-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  flex-shrink: 0;
  line-height: 1;
}

/* ── Passi guidati iOS ── */
.install-banner-steps {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.install-step {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
}

.install-step-num {
  width: 20px;
  height: 20px;
  min-width: 20px;
  border-radius: 50%;
  background: var(--accent);
  color: #ffffff;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.install-step-text {
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.5;
  flex: 1;
}

.install-pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: var(--accent-light);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 6px;
  vertical-align: middle;
  margin: 0 2px;
  white-space: nowrap;
}

.install-pill span {
  color: var(--accent);
  font-size: 10px;
  font-weight: 600;
}

/* ── Banner Android ── */
.install-banner-android-inner {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
}

.android-app-icon {
  width: 36px;
  height: 36px;
  background: var(--bg-elevated);
  border: 1.5px solid var(--border-strong);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.android-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.android-title {
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
}

.android-sub {
  color: var(--text-muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.install-banner-btn {
  background: var(--accent);
  color: #ffffff;
  border: none;
  border-radius: 20px;
  padding: 8px 16px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  flex-shrink: 0;
}

/* ===== SCHERMATA ANALISI IN ATTESA ===== */

.analisi-attesa-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px 20px 12px;
  background: rgba(245, 246, 250, 0.96);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 10;
}

.analisi-attesa-logo {
  display: flex;
  align-items: center;
  gap: 8px;
}

.analisi-attesa-logo-icon {
  font-size: 1.4rem;
  filter: drop-shadow(0 0 5px rgba(13, 74, 136, 0.38));
}

.analisi-attesa-logo-text {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.02em;
}

.analisi-attesa-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 28px 24px 36px;
  text-align: center;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.analisi-attesa-foto {
  width: 100%;
  max-width: 300px;
  max-height: 200px;
  border-radius: var(--radius-md);
  object-fit: cover;
  border: 3px solid var(--accent);
  margin-bottom: 22px;
  transition: opacity 0.3s ease, filter 0.8s ease, border-color 0.5s ease;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

/* Filtri cromatici light-mode — ricalibrati per tema Slate */
.filtro-ciano { filter: sepia(0.12) hue-rotate(175deg) saturate(1.25) brightness(1.0); }
.filtro-verde { filter: sepia(0.12) hue-rotate(112deg) saturate(1.35) brightness(1.0); }
.filtro-viola { filter: sepia(0.12) hue-rotate(252deg) saturate(1.2)  brightness(1.0); }

.analisi-attesa-progress-wrap {
  width: 100%;
  max-width: 320px;
  margin-bottom: 18px;
}

.analisi-attesa-progress-bar {
  width: 100%;
  height: 6px;
  background: rgba(13, 74, 136, 0.1);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 6px;
}

.analisi-attesa-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent) 0%, #1a6bb5 100%);
  border-radius: 3px;
  transition-property: width;
  transition-timing-function: ease-out;
  transition-duration: 0.2s;
  box-shadow: 0 0 6px rgba(13, 74, 136, 0.28);
}

.analisi-attesa-progress-pct {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  text-align: right;
  opacity: 0.8;
  letter-spacing: 0.04em;
}

.analisi-attesa-msg-wrap {
  position: relative;
  overflow: hidden;
  height: 56px;
  width: 100%;
  max-width: 320px;
  margin-bottom: 20px;
}

.analisi-attesa-msg {
  position: absolute;
  width: 100%;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.4;
  transform: translateX(0);
  color: var(--accent);
}

.analisi-attesa-msg.slide-out {
  transform: translateX(100%);
  transition: transform 0.4s ease-out;
}

.analisi-attesa-msg-next {
  transform: translateX(-100%);
}

.analisi-attesa-msg-next.slide-in-next {
  transform: translateX(0);
  transition: transform 0.4s ease-out;
}

.analisi-attesa-paziente {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-top: 4px;
}

/* ===== VALUTAZIONE — REFERTO AI STRUTTURATO ===== */

/* Badge qualità / azione / tipo eziologico */
.ai-badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 6px;
  letter-spacing: 0.04em;
}

.ai-badge-quality  { background: var(--success-light); color: var(--success); }
.ai-badge-urgency  { background: var(--warning-light); color: var(--warning); }
.ai-badge-etiology { background: var(--accent-light);  color: var(--accent);  }

/* Testo riepilogo */
.ai-summary-text {
  font-size: 15px;
  line-height: 1.7;
  color: var(--text-primary);
  margin: 0 0 14px;
}

/* Separatore riepilogo → reperti */
.ai-section-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 4px 0 8px;
}

/* Riga singolo reperto */
.finding-row {
  display: flex;
  gap: 10px;
  padding: 12px 0;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.finding-row:first-of-type {
  border-top: none;
  padding-top: 4px;
}

/* Pallino severità */
.finding-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 5px;
}

/* Etichetta reperto */
.finding-label {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}

/* Badge certezza — colori distinti per livello */
.finding-certainty {
  font-size: 11px;
  padding: 2px 9px;
  border-radius: 4px;
  font-weight: 600;
}

.finding-certainty-verde  { background: var(--success-light); color: var(--success); }
.finding-certainty-giallo { background: var(--warning-light); color: var(--warning); }
.finding-certainty-grigio { background: #e8eaf2; color: var(--text-secondary); }

/* Testo descrittivo reperto */
.finding-detail {
  font-size: 14px;
  color: var(--text-secondary);
  margin: 5px 0 0;
  line-height: 1.65;
}

/* Box "lesione non rilevata" */
.lesione-non-trovata {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 12px;
  background: var(--bg-card);
}

/* Approfondimenti raccomandati */
.followups-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.followups-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.followup-pill {
  font-size: 12px;
  font-weight: 500;
  padding: 5px 12px;
  border-radius: 5px;
  background: var(--accent-light);
  color: var(--accent);
  border: 1px solid var(--border);
}

/* Dettaglio analisi completo (full_text formattato) */
.referto-raw-text {
  font-size: 13px;
  line-height: 1.75;
  color: var(--text-secondary);
  background: var(--bg-deep);
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  margin-top: 12px;
  border: 1px solid var(--border);
}

.referto-step-divider {
  border: none;
  border-top: 0.5px solid #c8cfe0;
  margin: 10px 0 8px;
}

.referto-step-title {
  display: block;
  font-weight: 600;
  color: #0d4a88;
  margin-top: 0;
  margin-bottom: 3px;
}

.referto-step-title + p,
.referto-step-title + div {
  margin-top: 2px;
}

/* Disclaimer — usato sia nel testo AI inline che come <p> statico */
.referto-disclaimer {
  display: block;
  border-top: 1px solid #c8cfe0;
  margin-top: 16px;
  padding-top: 10px;
  font-size: 12px;
  color: #7a839a;
  line-height: 1.6;
}

/* Testo inline nei risultati elenco e dettaglio */
.text-muted    { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }

.text-muted-sm {
  font-size: 13px;
  color: var(--text-muted);
}

.text-body {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.65;
}
