/* =============================================================================
   LIS Refertazione Lab — report.css
   Dettaglio referto, tabella risultati, barra riepilogo,
   pannello interpretazione, visualizzatore PDF
   ============================================================================= */

/* =============================================================================
   DETTAGLIO REFERTO — Card paziente
   ============================================================================= */
.patient-card {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border-light);
  margin-bottom: var(--space-4);
}

.patient-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}

.patient-card-name {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-bold);
  color: var(--color-text);
}

.patient-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-3) var(--space-5);
}

.patient-card-field {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.patient-card-field .field-label {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: var(--font-weight-medium);
}

.patient-card-field .field-value {
  font-size: var(--font-size-sm);
  color: var(--color-text);
  font-weight: var(--font-weight-medium);
}

.patient-card-field .field-value.mono {
  font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
  letter-spacing: 0.5px;
}

/* Toolbar azioni referto — STICKY in alto durante lo scroll */
.report-toolbar {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  padding: var(--space-3) var(--space-4);
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  border: 1px solid var(--color-border-light);
  margin-bottom: var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  /* Sticky: resta visibile appena sotto il topbar fisso */
  position: sticky;
  top: var(--topbar-height, 56px);
  z-index: 50;
  /* Effetto "glassmorphism" leggero quando scorri sotto */
  backdrop-filter: saturate(160%) blur(4px);
  -webkit-backdrop-filter: saturate(160%) blur(4px);
  background: rgba(255, 255, 255, 0.96);
}

/* Quando la toolbar diventa sticky (stuck), ombra più pronunciata */
.report-toolbar.is-stuck {
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  border-color: var(--color-border);
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.toolbar-separator {
  width: 1px;
  height: 28px;
  background: var(--color-border);
  margin: 0 var(--space-2);
}

/* Bottoni generici */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border: 1.5px solid transparent;
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  cursor: pointer;
  transition: all var(--transition-base);
  white-space: nowrap;
  line-height: 1.4;
}

.btn svg {
  width: 16px; height: 16px;
  fill: none; stroke: currentColor; stroke-width: 2;
  flex-shrink: 0;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--color-primary); color: #ffffff;
  border-color: var(--color-primary);
}
.btn-primary:hover:not(:disabled) {
  background: var(--color-primary-dark);
  box-shadow: 0 2px 8px rgba(15, 118, 110, 0.3);
}

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

.btn-success {
  background: var(--color-success); color: #ffffff;
  border-color: var(--color-success);
}
.btn-success:hover:not(:disabled) {
  background: #15803d;
  box-shadow: 0 2px 8px rgba(22, 163, 74, 0.3);
}

.btn-warning {
  background: var(--color-warning); color: #ffffff;
  border-color: var(--color-warning);
}
.btn-warning:hover:not(:disabled) {
  background: #b45309;
  box-shadow: 0 2px 8px rgba(217, 119, 6, 0.3);
}

.btn-danger {
  background: var(--color-danger); color: #ffffff;
  border-color: var(--color-danger);
}
.btn-danger:hover:not(:disabled) {
  background: #b91c1c;
  box-shadow: 0 2px 8px rgba(220, 38, 38, 0.3);
}

.btn-outline {
  background: transparent; color: var(--color-primary);
  border-color: var(--color-primary);
}
.btn-outline:hover:not(:disabled) { background: var(--color-primary-50); }

.btn-ghost {
  background: transparent; color: var(--color-text-secondary);
  border-color: transparent;
}
.btn-ghost:hover:not(:disabled) {
  background: var(--color-surface-hover); color: var(--color-text);
}

.btn-sm {
  padding: var(--space-1) var(--space-3);
  font-size: var(--font-size-xs);
}
.btn-sm svg { width: 14px; height: 14px; }

.btn-lg {
  padding: var(--space-3) var(--space-6);
  font-size: var(--font-size-md);
}

/* =============================================================================
   TABELLA RISULTATI
   ============================================================================= */
.results-table-wrapper {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border-light);
  /* 10/09/2026 — era `overflow: hidden`, e su schermi stretti tagliava la parte
     destra della tabella SENZA barra di scorrimento: il pulsante "Apri in LAB-Gluc"
     nell'intestazione di gruppo finiva fuori e non c'era modo di raggiungerlo.
     Questa regola arriva dopo quella di layout.css (`overflow-x: auto`) e la
     annullava. Ora scorre in orizzontale e resta tagliato solo in verticale,
     che e' quel che serve agli angoli arrotondati. */
  overflow-x: auto;
  overflow-y: hidden;
  margin-bottom: var(--space-4);
}

.results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-size-sm);
}

.results-table thead th {
  padding: var(--space-3) var(--space-3);
  text-align: left;
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 2px solid var(--color-border);
  background: var(--color-bg);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 5;
}

.results-table thead th.col-checkbox { width: 32px; text-align: center; }
.results-table thead th.col-test { min-width: 180px; }
.results-table thead th.col-lis { min-width: 80px; text-align: right; }
.results-table thead th.col-value { min-width: 110px; }
.results-table thead th.col-unit { min-width: 70px; white-space: nowrap; }
.results-table thead th.col-ref { min-width: 130px; }
.results-table thead th.col-flag { width: 36px; text-align: center; }
.results-table thead th.col-history { min-width: 220px; }
.results-table thead th.col-note { width: 40px; text-align: center; }

/* Riga intestazione gruppo — molto più visibile per distinguere pannelli */
.results-table .group-header td {
  padding: 10px 16px 10px 22px;
  font-size: calc(13px*var(--fs,1));
  font-weight: 700;
  color: #1f2937;
  text-transform: uppercase;
  letter-spacing: 1px;
  background: linear-gradient(90deg, #f1f5f9 0%, #f8fafc 60%, #ffffff 100%);
  border-top: 2px solid #cbd5e1;
  border-bottom: 1px solid #e2e8f0;
  position: relative;
  box-shadow: 0 1px 0 rgba(0,0,0,0.02);
}

/* Stripe verticale colorata per categoria */
.results-table .group-header td::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 6px;
  background: #94a3b8;
}

.results-table .group-header td > * { vertical-align: middle; }

/* Tinta soft di sfondo + stripe colorata per ciascuna categoria */
.results-table .group-header.group-ematologia td { background: linear-gradient(90deg, #fef2f2 0%, #fff5f5 60%, #ffffff 100%); }
.results-table .group-header.group-ematologia td::before { background: var(--group-ematologia); }

.results-table .group-header.group-chimica td { background: linear-gradient(90deg, #eff6ff 0%, #f5faff 60%, #ffffff 100%); }
.results-table .group-header.group-chimica td::before { background: var(--group-chimica); }

.results-table .group-header.group-enzimi td { background: linear-gradient(90deg, #f5f3ff 0%, #faf8ff 60%, #ffffff 100%); }
.results-table .group-header.group-enzimi td::before { background: var(--group-enzimi); }

.results-table .group-header.group-lipidi td { background: linear-gradient(90deg, #fffbeb 0%, #fffcf3 60%, #ffffff 100%); }
.results-table .group-header.group-lipidi td::before { background: var(--group-lipidi); }

.results-table .group-header.group-coagulazione td { background: linear-gradient(90deg, #ecfeff 0%, #f0fdfa 60%, #ffffff 100%); }
.results-table .group-header.group-coagulazione td::before { background: var(--group-coagulazione); }

.results-table .group-header.group-urine td { background: linear-gradient(90deg, #f7fee7 0%, #fafff0 60%, #ffffff 100%); }
.results-table .group-header.group-urine td::before { background: var(--group-urine); }

.results-table .group-header.group-ormoni td { background: linear-gradient(90deg, #fdf2f8 0%, #fef5fa 60%, #ffffff 100%); }
.results-table .group-header.group-ormoni td::before { background: var(--group-ormoni); }

.results-table .group-header.group-sierologia td { background: linear-gradient(90deg, #fff7ed 0%, #fffaf3 60%, #ffffff 100%); }
.results-table .group-header.group-sierologia td::before { background: var(--group-sierologia); }

.results-table .group-header.group-markers td { background: linear-gradient(90deg, #eef2ff 0%, #f3f5ff 60%, #ffffff 100%); }
.results-table .group-header.group-markers td::before { background: var(--group-markers); }

.results-table .group-header.group-feci td { background: linear-gradient(90deg, #fef3c7 0%, #fffbeb 60%, #ffffff 100%); }
.results-table .group-header.group-feci td::before { background: var(--group-feci); }

.results-table .group-header.group-microbiologia td { background: linear-gradient(90deg, #d1fae5 0%, #ecfdf5 60%, #ffffff 100%); }
.results-table .group-header.group-microbiologia td::before { background: var(--group-microbiologia); }

.results-table .group-header.group-spermio td { background: linear-gradient(90deg, #fce7f3 0%, #fdf2f8 60%, #ffffff 100%); }
.results-table .group-header.group-spermio td::before { background: var(--group-spermio); }

.results-table .group-header.group-elettroforesi td { background: linear-gradient(90deg, #dbeafe 0%, #eff6ff 60%, #ffffff 100%); }
.results-table .group-header.group-elettroforesi td::before { background: var(--group-elettroforesi); }

.results-table .group-header.group-autoimmunita td { background: linear-gradient(90deg, #fef3c7 0%, #fffbeb 60%, #ffffff 100%); }
.results-table .group-header.group-autoimmunita td::before { background: var(--group-autoimmunita); }

.results-table .group-header.group-tiroide td { background: linear-gradient(90deg, #ccfbf1 0%, #f0fdfa 60%, #ffffff 100%); }
.results-table .group-header.group-tiroide td::before { background: var(--group-tiroide); }

.results-table .group-header.group-cardio td { background: linear-gradient(90deg, #ffe4e6 0%, #fff1f2 60%, #ffffff 100%); }
.results-table .group-header.group-cardio td::before { background: var(--group-cardio); }

.results-table .group-header.group-tossicologia td { background: linear-gradient(90deg, #e0e7ff 0%, #eef2ff 60%, #ffffff 100%); }
.results-table .group-header.group-tossicologia td::before { background: var(--group-tossicologia); }

/* Righe risultati */
.results-table tbody tr {
  border-bottom: 1px solid var(--color-border-light);
  transition: background var(--transition-fast);
}

.results-table tbody tr:not(.group-header):hover {
  background: var(--color-surface-hover);
}

.results-table tbody td {
  padding: var(--space-2) var(--space-3);
  vertical-align: middle;
  white-space: normal;
  word-break: break-word;
  overflow: visible;
}

.results-table tbody td.td-checkbox { text-align: center; }

.results-table tbody td.td-checkbox input[type="checkbox"] {
  width: 16px; height: 16px;
  accent-color: var(--color-primary);
  cursor: pointer;
}

.results-table .test-name {
  font-weight: var(--font-weight-medium);
  color: var(--color-text);
}

.results-table .lis-value {
  color: var(--color-text-muted);
  font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
  font-size: calc(11px*var(--fs,1));
  text-align: right;
  display: block;
}

/* Input valore: auto-ridimensionamento in base al contenuto */
.results-table .value-input {
  width: 100%;
  min-width: 90px;
  height: auto;
  min-height: 30px;
  padding: 4px 8px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: calc(13px*var(--fs,1));
  font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
  color: var(--color-text);
  background: var(--color-surface);
  outline: none;
  transition: all var(--transition-fast);
  text-align: right;
  box-sizing: border-box;
  /* Auto-dimensionamento moderno (Chrome 123+/Edge) */
  field-sizing: content;
}

/* Select qualitativo: auto-grow + testo sinistra (più leggibile per testo lungo) */
.results-table .value-input.value-select {
  min-width: 140px;
  text-align: left;
  field-sizing: content;
  padding-right: 20px;  /* spazio per la freccia */
}

/* Quando il valore contiene testo non numerico, allinea a sinistra */
.results-table input.value-input[data-mode="text"],
.results-table input.value-input:not([type="number"]) {
  /* Allineamento dinamico applicato via JS (vedi report-table.js) */
}

.results-table .value-input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.12);
}

.results-table .unit-text {
  font-size: var(--font-size-xs);
  color: var(--color-text-secondary);
  white-space: nowrap;
}

.results-table .ref-range {
  font-size: var(--font-size-xs);
  color: var(--color-text-secondary);
  font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
  white-space: normal;
  word-break: break-word;
  display: inline-block;
  line-height: 1.35;
}

.results-table .lis-value {
  white-space: normal;
  word-break: break-word;
}

/* Commento: espandibile */
.results-table .comment-input {
  width: 100% !important;
  min-width: 140px;
  field-sizing: content;
  resize: horizontal;
}

/* Colonna storico analisi */
.history-cell {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 200px;
}

.history-cell .sparkline-container {
  width: 80px; height: 28px; flex-shrink: 0;
}

.history-cell .sparkline-container canvas {
  width: 100%; height: 100%;
}

.history-cell .history-values {
  display: flex;
  flex-direction: column;
  gap: 1px;
  font-size: calc(10px*var(--fs,1));
  font-family: 'SF Mono', monospace;
  color: var(--color-text-secondary);
  line-height: 1.3;
}

.history-cell .history-values .hv-item {
  display: flex; gap: 4px; white-space: nowrap;
}

.history-cell .history-values .hv-date {
  color: var(--color-text-muted); font-size: calc(9px*var(--fs,1));
}

.history-cell .history-values .hv-val {
  font-weight: 600; color: var(--color-text);
}

.history-cell .history-values .hv-val.hv-high { color: var(--color-danger); }
.history-cell .history-values .hv-val.hv-low { color: var(--color-info); }

.history-cell .history-trend {
  font-size: calc(10px*var(--fs,1)); font-weight: 600;
  padding: 1px 4px; border-radius: 3px;
}

.history-cell .history-trend.trend-up {
  color: var(--color-danger); background: rgba(220, 38, 38, 0.08);
}

.history-cell .history-trend.trend-down {
  color: var(--color-info); background: rgba(37, 99, 235, 0.08);
}

.history-cell .history-trend.trend-stable {
  color: var(--color-success); background: rgba(22, 163, 74, 0.08);
}

/* Flag alto/basso/normale */
.flag-indicator {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px; height: 24px;
  border-radius: var(--radius-full);
  font-size: calc(10px*var(--fs,1));
  font-weight: var(--font-weight-bold);
}

.flag-high { background: var(--color-danger-light); color: var(--color-danger); }
.flag-low { background: var(--color-info-light); color: var(--color-info); }
.flag-normal { background: var(--color-success-light); color: var(--color-success); }
.flag-reval { background: #fef3c7; color: #b45309; }
/* 04/11/2026: riga senza valore di riferimento, stessa scritta del PDF */
.flag-indicator.flag-non-normato {
  width: auto; height: auto;
  padding: 3px 8px;
  white-space: nowrap;
  font-size: calc(9.5px*var(--fs,1));
  background: rgba(100, 116, 139, 0.14);
  color: #64748b;
}

/* Righe con flag */
.results-table tbody tr.row-flag-high { background: rgba(220, 38, 38, 0.04); }
.results-table tbody tr.row-flag-high .test-name { color: var(--color-danger); }
.results-table tbody tr.row-flag-high .value-input {
  color: var(--color-danger); font-weight: var(--font-weight-bold);
  border-color: rgba(220, 38, 38, 0.3);
}

.results-table tbody tr.row-flag-low { background: rgba(37, 99, 235, 0.04); }
.results-table tbody tr.row-flag-low .test-name { color: var(--color-info); }
.results-table tbody tr.row-flag-low .value-input {
  color: var(--color-info); font-weight: var(--font-weight-bold);
  border-color: rgba(37, 99, 235, 0.3);
}

/* "Da rivalutare" (arancione): valore fuori dal range base ma dentro fasce gravidanza/ciclo */
.results-table tbody tr.row-flag-reval { background: rgba(245, 158, 11, 0.06); }
.results-table tbody tr.row-flag-reval .test-name { color: #b45309; }
.results-table tbody tr.row-flag-reval .value-input {
  color: #b45309; font-weight: var(--font-weight-bold);
  border-color: rgba(245, 158, 11, 0.35);
}

/* Riga evidenziata da IA (es. Rule of Three HCT/HGB violata): pulsazione visiva */
.results-table tbody tr.row-ai-flagged {
  background: rgba(245, 158, 11, 0.12);
  border-left: 4px solid #f59e0b !important;
  animation: ai-flag-pulse 1.8s ease-in-out infinite;
}
.results-table tbody tr.row-ai-flagged .test-name {
  color: #92400e; font-weight: var(--font-weight-bold);
}
.results-table tbody tr.row-ai-flagged .value-input {
  background: #fef3c7;
  border-color: #f59e0b;
  color: #78350f; font-weight: var(--font-weight-bold);
}
@keyframes ai-flag-pulse {
  0%, 100% { background-color: rgba(245, 158, 11, 0.10); }
  50%      { background-color: rgba(245, 158, 11, 0.30); }
}
/* HARD GUARD — la Regola del 3 vale SOLO per HCT in emocromo: indipendentemente
   da quale path JS abbia inserito badge/classi, nasconde tutto su righe non-HCT. */
.results-table tbody tr:not([data-test-code="HCT"]) .rule3-warning,
.results-table tbody tr:not([data-test-code="HCT"]) .rule-three-badge { display: none !important; }
.results-table tbody tr:not([data-test-code="HCT"]).row-ai-flagged {
  background: transparent !important;
  border-left: none !important;
  animation: none !important;
}
.results-table tbody tr:not([data-test-code="HCT"]).row-ai-flagged .test-name { color: inherit !important; }

/* RIPRISTINO discordanza Proteine Totali (Metabolismo TP vs Elettroforesi 260A):
   la HARD GUARD sopra è solo-HCT e spegne row-ai-flagged anche sulle proteine,
   dove invece l'evidenziazione SERVE. Ri-abilito SOLO le righe che hanno l'alert
   di discordanza proteine (.proteine-disc-warning) — la Regola del 3 (HCT) resta
   intatta, nient'altro viene toccato. */
.results-table tbody tr.row-ai-flagged:has(.proteine-disc-warning) {
  background: rgba(245, 158, 11, 0.12) !important;
  border-left: 4px solid #f59e0b !important;
}
.results-table tbody tr.row-ai-flagged:has(.proteine-disc-warning) .test-name {
  color: #92400e !important; font-weight: var(--font-weight-bold);
}
.results-table tbody tr.row-ai-flagged:has(.proteine-disc-warning) .value-input {
  background: #fef3c7 !important; border-color: #f59e0b !important;
  color: #78350f !important; font-weight: var(--font-weight-bold);
}
/* Alert di discordanza ben visibile (non aveva stile dedicato → ereditava il default) */
.results-table tbody tr .proteine-disc-warning {
  display: block; margin-top: 3px; font-size: calc(12px*var(--fs,1));
  color: #b45309; font-weight: 600;
}

/* 20/10/2026 — VALORE 0 NON CONSENTITO (spunta «Valore 0 refertabile» tolta nel nomenclatore): stessa grafica
   della discordanza Proteine Totali; la HARD GUARD solo-HCT qui sopra la spegnerebbe, si riabilita come per le proteine. */
.results-table tbody tr.row-ai-flagged:has(.zero-vietato-warning) {
  background: rgba(245, 158, 11, 0.12) !important;
  border-left: 4px solid #f59e0b !important;
  animation: ai-flag-pulse 1.8s ease-in-out infinite !important;
}
.results-table tbody tr.row-ai-flagged:has(.zero-vietato-warning) .test-name {
  color: #92400e !important; font-weight: var(--font-weight-bold);
}
.results-table tbody tr.row-ai-flagged:has(.zero-vietato-warning) .value-input {
  background: #fef3c7 !important; border-color: #f59e0b !important;
  color: #78350f !important; font-weight: var(--font-weight-bold);
}
.results-table tbody tr .zero-vietato-warning {
  display: block; margin-top: 3px; font-size: calc(12px*var(--fs,1));
  color: #b45309; font-weight: 600;
}

/* Testo "Regola del 3 non rispettata" sotto il nome test (solo WL, mai PDF) */
.rule3-warning {
  display: inline-block;
  margin-top: 3px;
  padding: 2px 8px;
  background: #dc2626;
  color: #fff;
  font-size: calc(10.5px*var(--fs,1));
  font-weight: 700;
  border-radius: 4px;
  letter-spacing: .2px;
  cursor: help;
  box-shadow: 0 1px 3px rgba(220, 38, 38, .4);
  animation: rule3-blink 1s steps(1, end) infinite;
}
@keyframes rule3-blink {
  0%, 49%   { opacity: 1; }
  50%, 100% { opacity: .35; }
}
/* Riga HCT flaggata: bordo più marcato + nome test rosso */
.results-table tbody tr.row-ai-flagged {
  border-left-width: 5px !important;
}
.results-table tbody tr.row-ai-flagged .test-name {
  color: #b91c1c;
}

/* Sparkline storia */
.sparkline-container {
  width: 70px; height: 24px;
  display: inline-block; vertical-align: middle;
}
.sparkline-container canvas { width: 100%; height: 100%; }

/* Bottone nota */
.note-btn {
  background: none; border: none; cursor: pointer;
  padding: var(--space-1); border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  transition: all var(--transition-fast);
}

.note-btn:hover {
  background: var(--color-surface-hover); color: var(--color-primary);
}

.note-btn.has-note { color: var(--color-warning); }

.note-btn svg {
  width: 16px; height: 16px;
  fill: none; stroke: currentColor; stroke-width: 2;
}

/* =============================================================================
   BARRA RIEPILOGO (sticky bottom)
   ============================================================================= */
.summary-bar {
  position: sticky;
  bottom: 0;
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  padding: var(--space-3) var(--space-5);
  display: flex;
  align-items: center;
  gap: var(--space-6);
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.04);
  z-index: 20;
  border-radius: 0 0 var(--radius-xl) var(--radius-xl);
}

.summary-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
}

.summary-counter {
  font-weight: var(--font-weight-bold);
  font-size: var(--font-size-md);
  padding: 2px 10px;
  border-radius: var(--radius-full);
}

.summary-counter.total { background: var(--color-bg); color: var(--color-text); }
.summary-counter.out-of-range { background: var(--color-warning-50); color: var(--color-warning); }
.summary-counter.pathological { background: var(--color-danger-50); color: var(--color-danger); }

/* =============================================================================
   PANNELLO INTERPRETAZIONE
   ============================================================================= */
.interpretation-panel {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border-light);
  overflow: hidden;
  margin-bottom: var(--space-4);
}

.interpretation-header {
  padding: var(--space-4) var(--space-5);
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.interpretation-header:hover { background: var(--color-surface-hover); }

.interpretation-header h3 {
  font-size: var(--font-size-md);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.interpretation-header h3 svg {
  width: 18px; height: 18px;
  fill: none; stroke: currentColor; stroke-width: 2;
}

.interpretation-toggle svg {
  width: 18px; height: 18px;
  fill: none; stroke: currentColor; stroke-width: 2;
  color: var(--color-text-muted);
  transition: transform var(--transition-fast);
}

.interpretation-panel.open .interpretation-toggle svg {
  transform: rotate(180deg);
}

.interpretation-body {
  padding: 0 var(--space-5) var(--space-5);
  display: none;
}

.interpretation-panel.open .interpretation-body { display: block; }

.interpretation-item {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-2);
  border-left: 4px solid transparent;
  font-size: var(--font-size-sm);
  line-height: 1.6;
}

.interpretation-item.level-info {
  background: var(--color-info-50);
  border-left-color: var(--color-info);
  color: #1e40af;
}

.interpretation-item.level-warning {
  background: var(--color-warning-50);
  border-left-color: var(--color-warning);
  color: #92400e;
}

.interpretation-item.level-danger {
  background: var(--color-danger-50);
  border-left-color: var(--color-danger);
  color: #991b1b;
}

.interpretation-item strong { font-weight: var(--font-weight-semibold); }

/* =============================================================================
   VISUALIZZATORE PDF
   ============================================================================= */
.pdf-viewer {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border-light);
  overflow: hidden;
}

.pdf-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
}

.pdf-toolbar-left {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  font-weight: var(--font-weight-medium);
}

.pdf-toolbar-right {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.pdf-embed {
  width: 100%;
  height: calc(100vh - 280px);
  min-height: 500px;
  border: none;
  display: block;
}

/* =============================================================================
   FASE 6 — Commenti, allegati, urine qualitative
   ============================================================================= */

/* Colonna commento inline */
.results-table .comment-input {
  width: 140px;
  height: 24px;
  padding: 2px 4px;
  border: none;
  border-bottom: 1px solid var(--color-border-light);
  background: transparent;
  font-size: calc(11px*var(--fs,1));
  color: var(--color-text);
  outline: none;
  transition: border-color var(--transition-fast);
}

.results-table .comment-input:focus {
  border-bottom-color: var(--color-primary);
}

.results-table .comment-input::placeholder {
  color: var(--color-text-muted);
  font-style: italic;
}

/* Colonna allegato */
.results-table .attach-btn {
  background: none;
  border: 1px solid var(--color-border);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  font-size: calc(11px*var(--fs,1));
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.results-table .attach-btn:hover {
  background: var(--color-surface-hover);
  color: var(--color-primary);
  border-color: var(--color-primary-light);
}

.results-table .attach-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  background: var(--color-primary-50);
  color: var(--color-primary);
  font-size: calc(10px*var(--fs,1));
  font-weight: var(--font-weight-medium);
  max-width: 120px;
}

.results-table .attach-badge .attach-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.results-table .attach-remove {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-danger);
  font-size: calc(12px*var(--fs,1));
  padding: 0;
  line-height: 1;
}

/* Select qualitativo per urine */
.results-table .urine-select {
  width: 100%;
  height: 28px;
  padding: 0 4px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: calc(12px*var(--fs,1));
  color: var(--color-text);
  background: var(--color-surface);
  outline: none;
  transition: all var(--transition-fast);
  cursor: pointer;
}

.results-table .urine-select:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.12);
}

/* Toolbar importazione grafici */
.results-import-toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border-light);
}

.results-import-toolbar .import-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text-secondary);
  font-size: var(--font-size-xs);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.results-import-toolbar .import-btn:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
  background: var(--color-primary-50);
}

.results-import-toolbar .import-btn svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
}
