/* =============================================================================
   LIS Refertazione Lab — spermiogram.css
   Port ESATTO di LAB-Spermiogrammi css/styles.css
   Prefisso .spermio-app per evitare conflitti con il layout LIS
   ============================================================================= */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;600;700&family=Source+Serif+4:wght@400;600;700&display=swap');

/* =============================================================================
   1. ROOT VARIABILI (sotto scope .spermio-app)
   ============================================================================= */

.spermio-app {
  --sp-bg: #f0f3f7;
  --sp-surface: #fff;
  --sp-surface-alt: #f7f9fb;
  --sp-primary: #1a5276;
  --sp-primary-light: #2980b9;
  --sp-primary-pale: #eaf4fb;
  --sp-accent: #16a085;
  --sp-accent-pale: #e8f8f5;
  --sp-text: #1a1a1a;
  --sp-text-secondary: #5a5a5a;
  --sp-text-muted: #8a8a8a;
  --sp-border: #dce4ec;
  --sp-border-light: #eaeff4;
  --sp-warning: #d4a017;
  --sp-warning-pale: #fef9e7;
  --sp-danger: #c0392b;
  --sp-danger-pale: #fdecea;
  --sp-success: #27ae60;
  --sp-success-pale: #e8f8ef;
  --sp-shadow-sm: 0 1px 3px rgba(0,0,0,.06);
  --sp-shadow-md: 0 4px 12px rgba(0,0,0,.08);
  --sp-shadow-lg: 0 8px 30px rgba(0,0,0,.10);
  --sp-radius: 10px;
  --sp-radius-lg: 16px;
  font-family: 'DM Sans', system-ui, sans-serif;
  color: var(--sp-text);
  line-height: 1.6;
}
.spermio-app h1, .spermio-app h2, .spermio-app h3 {
  font-family: 'Source Serif 4', Georgia, serif;
}

/* =============================================================================
   2. SECTION TABS
   ============================================================================= */

.spermio-app .section-tabs {
  display: flex; gap: 3px; margin-bottom: 18px;
  background: var(--sp-surface); padding: 4px;
  border-radius: var(--sp-radius-lg); box-shadow: var(--sp-shadow-sm);
  flex-wrap: wrap;
}
.spermio-app .section-tab {
  flex: 1; padding: 9px 8px; border: none; background: transparent;
  border-radius: var(--sp-radius); cursor: pointer;
  font-size: calc(11px*var(--fs,1)); font-weight: 500; color: var(--sp-text-secondary);
  transition: all .2s; white-space: nowrap;
}
.spermio-app .section-tab:hover {
  background: var(--sp-primary-pale); color: var(--sp-primary);
}
.spermio-app .section-tab.active {
  background: var(--sp-primary); color: #fff; box-shadow: var(--sp-shadow-sm);
}

/* =============================================================================
   3. CARDS (struttura categorie)
   ============================================================================= */

.spermio-app .card {
  background: var(--sp-surface);
  border-radius: var(--sp-radius-lg);
  box-shadow: var(--sp-shadow-sm);
  border: 1px solid var(--sp-border-light);
  margin-bottom: 18px;
  overflow: hidden;
}
.spermio-app .card-header {
  padding: 12px 20px;
  border-bottom: 1px solid var(--sp-border-light);
  display: flex; align-items: center; gap: 10px;
  background: var(--sp-surface-alt);
}
.spermio-app .card-header h2 {
  font-size: calc(15px*var(--fs,1)); font-weight: 600; color: var(--sp-primary);
}
.spermio-app .card-header .icon {
  width: 28px; height: 28px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: calc(14px*var(--fs,1)); flex-shrink: 0;
}
.spermio-app .card-body {
  padding: 18px 20px;
}

/* =============================================================================
   4. CATEGORY BLOCKS (param-category con header colorato)
   ============================================================================= */

.spermio-app .param-category {
  margin-bottom: 14px;
  background: var(--sp-surface);
  border-radius: var(--sp-radius-lg);
  overflow: hidden;
  box-shadow: var(--sp-shadow-sm);
  border: 1px solid var(--sp-border-light);
}
.spermio-app .category-header,
.spermio-app .cat-header {
  padding: 10px 16px;
  display: flex; align-items: center; gap: 10px;
  background: linear-gradient(135deg, var(--cat-color), color-mix(in srgb, var(--cat-color) 70%, #fff));
  cursor: pointer;
}
.spermio-app .cat-icon { font-size: calc(18px*var(--fs,1)); }
.spermio-app .cat-header h3,
.spermio-app .category-header h3 {
  font-size: calc(14px*var(--fs,1)); font-weight: 600; color: #fff; flex: 1;
}
.spermio-app .cat-count {
  font-size: calc(10px*var(--fs,1)); color: rgba(255,255,255,.8);
}
.spermio-app .cat-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 22px; height: 22px; padding: 0 6px;
  border-radius: 11px;
  background: rgba(255,255,255,.25); color: #fff;
  font-size: calc(10px*var(--fs,1)); font-weight: 700;
}
.spermio-app .cat-body {
  padding: 8px 12px;
}
.spermio-app .cat-chevron {
  width: 18px; height: 18px; flex-shrink: 0;
  color: rgba(255,255,255,.7);
  transition: transform .2s;
}
/* Accordion open/close */
.spermio-app .param-category .cat-body { display: block; }
.spermio-app .param-category.collapsed .cat-body { display: none; }
.spermio-app .param-category.open .cat-chevron { transform: rotate(180deg); }

/* =============================================================================
   5. PARAMETER ROWS (griglia 3 colonne: 200px label, 180px input, 1fr ref)
   ============================================================================= */

.spermio-app .param-row {
  display: grid;
  grid-template-columns: 200px 180px 1fr;
  gap: 8px;
  align-items: center;
  padding: 6px 8px;
  border-radius: 6px;
  transition: all .15s;
  border: 1px solid transparent;
}
.spermio-app .param-row:hover {
  background: var(--sp-surface-alt);
}
.spermio-app .val-abnormal {
  background: var(--sp-danger-pale) !important;
  border-color: #e74c3c44;
}
.spermio-app .val-flagged {
  background: var(--sp-warning-pale) !important;
  border-color: #f39c1244;
}
.spermio-app .val-normal {
  background: var(--sp-success-pale);
  border-color: #27ae6022;
}
.spermio-app .param-name {
  display: flex; flex-direction: column; gap: 1px;
}
.spermio-app .param-label {
  font-size: calc(12px*var(--fs,1)); font-weight: 600; color: var(--sp-text);
}
.spermio-app .param-unit {
  font-size: calc(10px*var(--fs,1)); color: var(--sp-text-muted);
}
.spermio-app .param-input-wrap {
  min-width: 0;
}
.spermio-app .param-input {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--sp-border);
  border-radius: 6px;
  font-size: calc(13px*var(--fs,1)); font-weight: 600;
  font-family: inherit;
  transition: all .2s;
}
.spermio-app .param-input:focus {
  border-color: var(--sp-primary);
  box-shadow: 0 0 0 3px var(--sp-primary-pale);
  outline: none;
}
.spermio-app .param-input.computed {
  background: #f5f5f5;
  color: var(--sp-primary);
  font-style: italic;
  cursor: default;
}
.spermio-app .param-input.input-error {
  border-color: var(--sp-danger) !important;
  box-shadow: 0 0 0 3px var(--sp-danger-pale) !important;
  animation: spShake .3s;
}
@keyframes spShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}
.spermio-app .param-ref {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.spermio-app .ref-text {
  font-size: calc(10px*var(--fs,1)); color: var(--sp-text-muted); flex: 1;
}

/* =============================================================================
   6. EVAL BADGES (status N/H/L circolari)
   ============================================================================= */

.spermio-app .eval-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: calc(9px*var(--fs,1)); font-weight: 700;
  white-space: nowrap;
}
.spermio-app .eval-badge.ok,
.spermio-app .eval-normal {
  background: var(--sp-success-pale);
  color: var(--sp-success);
}
.spermio-app .eval-badge.low,
.spermio-app .eval-flagged {
  background: var(--sp-warning-pale);
  color: var(--sp-warning);
}
.spermio-app .eval-badge.high,
.spermio-app .eval-abnormal {
  background: var(--sp-danger-pale);
  color: var(--sp-danger);
}

/* =============================================================================
   7. VALIDATION BOXES (motilita, morfologia)
   ============================================================================= */

.spermio-app .validation-box {
  margin: 6px 0; min-height: 0;
}
.spermio-app .val-error {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 10px 14px;
  background: var(--sp-danger-pale);
  border: 1px solid #e74c3c44;
  border-radius: 8px;
  font-size: calc(12px*var(--fs,1)); color: var(--sp-danger); font-weight: 500;
  margin-bottom: 4px;
  animation: spFadeIn .3s;
}
.spermio-app .val-ok {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px;
  background: var(--sp-success-pale);
  border: 1px solid #27ae6044;
  border-radius: 8px;
  font-size: calc(12px*var(--fs,1)); color: var(--sp-success); font-weight: 500;
  margin-bottom: 4px;
}
.spermio-app .val-hint {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 8px 14px;
  background: var(--sp-primary-pale);
  border: 1px solid #2980b944;
  border-radius: 8px;
  font-size: calc(12px*var(--fs,1)); color: var(--sp-primary);
  margin-bottom: 4px;
}
.spermio-app .val-error-icon,
.spermio-app .val-ok-icon,
.spermio-app .val-hint-icon {
  font-size: calc(16px*var(--fs,1)); flex-shrink: 0;
}
@keyframes spFadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: none; }
}

/* =============================================================================
   8. DIAGNOSIS BOX (conclusioni)
   ============================================================================= */

.spermio-app .diagnosis-box {
  padding: 18px;
  border-radius: var(--sp-radius-lg);
  margin-bottom: 16px;
}
.spermio-app .diag-normal {
  background: linear-gradient(135deg, #e8f8ef, #d5f5e3);
  border: 2px solid #27ae60;
}
.spermio-app .diag-abnormal {
  background: linear-gradient(135deg, #fdecea, #f9e0de);
  border: 2px solid #c0392b;
}
.spermio-app .diag-header {
  font-size: calc(16px*var(--fs,1)); font-weight: 700; margin-bottom: 8px;
}
.spermio-app .diag-normal .diag-header { color: var(--sp-success); }
.spermio-app .diag-abnormal .diag-header { color: var(--sp-danger); }
.spermio-app .diag-list {
  display: flex; gap: 6px; flex-wrap: wrap;
}

/* Diagnosis Tags */
.spermio-app .diag-tag {
  display: inline-block;
  padding: 5px 14px;
  border-radius: 20px;
  font-size: calc(13px*var(--fs,1)); font-weight: 700;
}
.spermio-app .tag-normal {
  background: #27ae60; color: #fff;
}
.spermio-app .tag-abnormal {
  background: #c0392b; color: #fff;
}
.spermio-app .tag-empty {
  background: var(--sp-border); color: var(--sp-text-muted);
}

/* =============================================================================
   9. RESULT TABLE
   ============================================================================= */

.spermio-app .result-table-wrap {
  overflow-x: auto;
}
.spermio-app .result-table {
  width: 100%; border-collapse: collapse; font-size: calc(12px*var(--fs,1));
}
.spermio-app .result-table th {
  background: var(--sp-primary); color: #fff;
  padding: 8px 10px; text-align: left;
  font-size: calc(10px*var(--fs,1)); font-weight: 600; text-transform: uppercase;
}
.spermio-app .result-table td {
  padding: 6px 10px; border-bottom: 1px solid var(--sp-border-light);
}
.spermio-app .row-abnormal {
  background: var(--sp-danger-pale);
}
.spermio-app .row-flagged {
  background: var(--sp-warning-pale);
}
.spermio-app .cat-separator td {
  background: var(--sp-surface-alt);
  font-weight: 700; color: var(--sp-primary);
  font-size: calc(11px*var(--fs,1)); padding: 8px 10px;
  border-bottom: 2px solid var(--sp-border);
}
.spermio-app .rt-name { font-weight: 600; }
.spermio-app .rt-val { font-weight: 700; font-variant-numeric: tabular-nums; }
.spermio-app .rt-unit { color: var(--sp-text-muted); font-size: calc(11px*var(--fs,1)); }
.spermio-app .rt-ref { color: var(--sp-text-muted); font-size: calc(10px*var(--fs,1)); max-width: 200px; }

/* =============================================================================
   10. STATS GRID (riepilogo)
   ============================================================================= */

.spermio-app .stats-grid,
.spermio-app .result-stats {
  display: flex; gap: 12px; margin-bottom: 16px; flex-wrap: wrap;
}
.spermio-app .stat-item,
.spermio-app .result-stat {
  flex: 1; min-width: 100px;
  padding: 12px;
  background: var(--sp-surface);
  border-radius: var(--sp-radius);
  box-shadow: var(--sp-shadow-sm);
  text-align: center;
  border: 1px solid var(--sp-border-light);
}
.spermio-app .stat-item:hover,
.spermio-app .result-stat:hover {
  box-shadow: var(--sp-shadow-md);
}
.spermio-app .rs-val,
.spermio-app .stat-value {
  font-size: calc(22px*var(--fs,1)); font-weight: 700;
  color: var(--sp-primary);
  line-height: 1.2; margin-bottom: 2px;
}
.spermio-app .rs-red { color: var(--sp-danger) !important; }
.spermio-app .rs-label,
.spermio-app .stat-label {
  font-size: calc(10px*var(--fs,1)); color: var(--sp-text-muted);
  text-transform: uppercase; letter-spacing: .4px;
  font-weight: 500;
}

/* =============================================================================
   11. INTERPRETATION BOX
   ============================================================================= */

.spermio-app .interpretation-box {
  background: var(--sp-surface);
  border: 1px solid var(--sp-border-light);
  border-radius: var(--sp-radius-lg);
  margin-top: 16px; overflow: hidden;
}
.spermio-app .interp-header {
  padding: 10px 16px;
  background: var(--sp-primary-pale);
  font-weight: 700; font-size: calc(14px*var(--fs,1));
  color: var(--sp-primary);
}
.spermio-app .interp-body {
  padding: 14px 16px;
}
.spermio-app .interp-note {
  display: flex; gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--sp-border-light);
  font-size: calc(12px*var(--fs,1)); line-height: 1.5;
}
.spermio-app .interp-note:last-of-type { border-bottom: none; }
.spermio-app .interp-icon { font-size: calc(16px*var(--fs,1)); flex-shrink: 0; }
.spermio-app .interp-disclaimer {
  margin-top: 10px; padding: 8px 12px;
  background: var(--sp-warning-pale);
  border-radius: 6px;
  font-size: calc(10px*var(--fs,1)); color: var(--sp-warning);
  line-height: 1.5;
}

/* =============================================================================
   12. IMAGE UPLOAD (griglia max 4 foto)
   ============================================================================= */

.spermio-app .images-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-top: 12px;
}
.spermio-app .image-card {
  background: var(--sp-surface);
  border: 1px solid var(--sp-border-light);
  border-radius: var(--sp-radius);
  overflow: hidden;
  display: flex; flex-direction: column;
}
.spermio-app .image-card img {
  width: 100%; height: 160px; object-fit: cover; display: block;
  border-radius: var(--sp-radius) var(--sp-radius) 0 0;
}
.spermio-app .image-caption {
  padding: 6px 8px;
}
.spermio-app .image-caption input {
  width: 100%; height: 30px; padding: 0 8px;
  border: 1px solid var(--sp-border-light);
  border-radius: 4px;
  font-size: calc(11px*var(--fs,1)); color: var(--sp-text-secondary);
  background: var(--sp-surface-alt);
  outline: none; transition: border-color .2s;
}
.spermio-app .image-caption input:focus {
  border-color: var(--sp-primary);
}

/* Upload drop zone */
.spermio-app .upload-zone,
.spermio-app .drop-zone {
  border: 2px dashed var(--sp-border);
  border-radius: var(--sp-radius);
  padding: 20px; text-align: center;
  cursor: pointer; transition: all .2s;
  color: var(--sp-text-muted);
  font-size: calc(13px*var(--fs,1));
  min-height: 160px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 6px;
}
.spermio-app .upload-zone:hover,
.spermio-app .drop-zone:hover,
.spermio-app .drop-zone.active {
  border-color: var(--sp-primary);
  background: var(--sp-primary-pale);
}
.spermio-app .drop-icon {
  width: 32px; height: 32px; color: var(--sp-text-muted);
}

/* =============================================================================
   13. FORMS
   ============================================================================= */

.spermio-app .form-group {
  display: flex; flex-direction: column; gap: 3px; flex: 1; min-width: 0;
}
.spermio-app .form-group label {
  font-size: calc(10px*var(--fs,1)); font-weight: 600;
  color: var(--sp-text-muted);
  text-transform: uppercase; letter-spacing: .3px;
}
.spermio-app input[type="text"],
.spermio-app input[type="number"],
.spermio-app input[type="date"],
.spermio-app input[type="time"],
.spermio-app select,
.spermio-app textarea {
  padding: 7px 10px;
  border: 1px solid var(--sp-border);
  border-radius: 7px;
  font-size: calc(13px*var(--fs,1)); font-family: inherit;
  background: #fff;
  transition: border-color .2s;
}
.spermio-app input:focus,
.spermio-app select:focus,
.spermio-app textarea:focus {
  border-color: var(--sp-primary);
  outline: none;
  box-shadow: 0 0 0 3px var(--sp-primary-pale);
}
.spermio-app .grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.spermio-app .grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.spermio-app .grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }

/* =============================================================================
   14. BUTTONS
   ============================================================================= */

.spermio-app .btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 8px 16px; border: none; border-radius: 7px;
  font-size: calc(13px*var(--fs,1)); font-weight: 600;
  cursor: pointer; font-family: inherit;
  transition: all .15s;
}
.spermio-app .btn-sm {
  padding: 5px 10px; font-size: calc(11px*var(--fs,1)); border-radius: 5px;
}
.spermio-app .btn-lg {
  padding: 10px 22px; font-size: calc(14px*var(--fs,1));
}
.spermio-app .btn-primary {
  background: var(--sp-primary) !important;
  color: #fff !important; border: none !important;
}
.spermio-app .btn-primary:hover {
  background: var(--sp-primary-light) !important;
  transform: translateY(-1px);
  box-shadow: var(--sp-shadow-sm);
}
.spermio-app .btn-success {
  background: var(--sp-success) !important;
  color: #fff !important; border: none !important;
}
.spermio-app .btn-success:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}
.spermio-app .btn-danger {
  background: var(--sp-danger) !important;
  color: #fff !important; border: none !important;
}
.spermio-app .btn-outline {
  background: var(--sp-surface) !important;
  color: var(--sp-text-secondary) !important;
  border: 1px solid var(--sp-border) !important;
}
.spermio-app .btn-outline:hover {
  border-color: var(--sp-primary) !important;
  color: var(--sp-primary) !important;
}
.spermio-app .btn-outline-danger {
  background: transparent;
  color: var(--sp-danger);
  border: 1px solid var(--sp-danger);
  border-radius: 7px; font-weight: 600;
  cursor: pointer;
  padding: 5px 10px; font-size: calc(11px*var(--fs,1));
}
.spermio-app .btn-group {
  display: flex; gap: 6px; flex-wrap: wrap;
}

/* =============================================================================
   15. TOGGLE SWITCH (34x18px esatto da LAB-Spermiogrammi)
   ============================================================================= */

.spermio-app .toggle-switch,
.spermio-app .toggle-wrap {
  position: relative;
  display: inline-block;
  width: 34px; height: 18px;
  flex-shrink: 0;
}
.spermio-app .toggle-switch input,
.spermio-app .toggle-wrap input {
  opacity: 0; width: 0; height: 0;
}
.spermio-app .toggle-slider {
  position: absolute; cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: #ccc;
  border-radius: 18px;
  transition: .3s;
}
.spermio-app .toggle-slider:before {
  content: "";
  position: absolute;
  height: 12px; width: 12px;
  left: 3px; bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: .3s;
}
.spermio-app .toggle-switch input:checked + .toggle-slider,
.spermio-app .toggle-wrap input:checked + .toggle-slider {
  background: var(--sp-success);
}
.spermio-app .toggle-switch input:checked + .toggle-slider:before,
.spermio-app .toggle-wrap input:checked + .toggle-slider:before {
  transform: translateX(16px);
}

/* =============================================================================
   16. MODAL
   ============================================================================= */

.spermio-app .modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
  backdrop-filter: blur(3px);
}
.spermio-app .modal-box {
  background: var(--sp-surface);
  border-radius: var(--sp-radius-lg);
  padding: 24px;
  box-shadow: var(--sp-shadow-lg);
  max-height: 90vh; overflow-y: auto;
  width: 90%; max-width: 600px;
}
.spermio-app .modal-box h3 {
  font-size: calc(16px*var(--fs,1)); margin-bottom: 14px;
  color: var(--sp-primary);
}

/* =============================================================================
   17. SETTINGS (parametri configurazione)
   ============================================================================= */

.spermio-app .settings-toolbar {
  display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap;
}
.spermio-app .settings-stats {
  font-size: calc(12px*var(--fs,1)); color: var(--sp-text-secondary);
  margin-bottom: 12px; padding: 6px 10px;
  background: var(--sp-surface-alt);
  border-radius: 6px;
}
.spermio-app .settings-cat {
  margin-bottom: 8px;
  border: 1px solid var(--sp-border-light);
  border-radius: var(--sp-radius);
  overflow: hidden;
}
.spermio-app .settings-cat-header {
  padding: 8px 14px;
  background: linear-gradient(135deg, var(--cat-color), color-mix(in srgb, var(--cat-color) 70%, #fff));
  color: #fff; font-size: calc(13px*var(--fs,1)); font-weight: 600;
  cursor: pointer;
  display: flex; justify-content: space-between; align-items: center;
}
.spermio-app .scat-count { font-size: calc(10px*var(--fs,1)); opacity: .85; }
.spermio-app .settings-cat.collapsed .settings-cat-body { display: none; }
.spermio-app .settings-cat-body { padding: 6px 10px; }
.spermio-app .settings-param {
  display: flex; align-items: center; gap: 10px;
  padding: 5px 0;
  border-bottom: 1px solid var(--sp-border-light);
}
.spermio-app .settings-param:last-child { border-bottom: none; }
.spermio-app .sp-inactive { opacity: .45; }
.spermio-app .sp-info { flex: 1; min-width: 0; }
.spermio-app .sp-info strong { font-size: calc(12px*var(--fs,1)); }
.spermio-app .sp-meta {
  font-size: calc(10px*var(--fs,1)); color: var(--sp-text-muted); display: block;
}
.spermio-app .sp-ref {
  font-size: calc(9px*var(--fs,1)); color: var(--sp-primary-light); display: block;
}
.spermio-app .sp-actions {
  display: flex; gap: 4px; flex-shrink: 0;
}

/* =============================================================================
   18. ARCHIVE
   ============================================================================= */

.spermio-app .archive-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid var(--sp-border-light);
  gap: 10px;
}
.spermio-app .archive-item:last-child { border-bottom: none; }
.spermio-app .ai-main { flex: 1; min-width: 0; }
.spermio-app .ai-patient { font-size: calc(13px*var(--fs,1)); font-weight: 600; }
.spermio-app .ai-meta { font-size: calc(10px*var(--fs,1)); color: var(--sp-text-muted); }
.spermio-app .ai-diag { font-size: calc(11px*var(--fs,1)); font-weight: 600; margin-top: 2px; }
.spermio-app .ai-diag-normal { color: var(--sp-success); }
.spermio-app .ai-diag-abnormal { color: var(--sp-danger); }
.spermio-app .ai-actions { display: flex; gap: 4px; flex-shrink: 0; }

/* =============================================================================
   19. NOTE INTERPRETATIVE (box con bordo laterale colorato)
   ============================================================================= */

.spermio-app .note {
  padding: 12px 16px; margin-bottom: 10px;
  border: 1px solid var(--sp-border);
  border-left: 4px solid var(--sp-border);
  border-radius: 8px;
  background: var(--sp-surface);
}
.spermio-app .note .note-title {
  font-size: calc(13px*var(--fs,1)); font-weight: 700; margin-bottom: 2px;
}
.spermio-app .note .note-text {
  font-size: calc(12px*var(--fs,1)); color: var(--sp-text-secondary); line-height: 1.5;
}
.spermio-app .note.critical {
  border-left-color: var(--sp-danger);
  background: var(--sp-danger-pale);
}
.spermio-app .note.critical .note-title { color: var(--sp-danger); }
.spermio-app .note.warning {
  border-left-color: var(--sp-warning);
  background: var(--sp-warning-pale);
}
.spermio-app .note.warning .note-title { color: var(--sp-warning); }
.spermio-app .note.info {
  border-left-color: var(--sp-primary);
  background: var(--sp-primary-pale);
}
.spermio-app .note.info .note-title { color: var(--sp-primary); }

/* =============================================================================
   20. UTILITY
   ============================================================================= */

.spermio-app .hidden { display: none !important; }
.spermio-app .fade-in { animation: spFadeIn .3s ease; }
.spermio-app .divider {
  height: 1px; background: var(--sp-border-light); margin: 16px 0;
}
.spermio-app .form-textarea {
  width: 100%; resize: vertical; min-height: 80px;
  padding: 10px 12px;
  border: 1px solid var(--sp-border);
  border-radius: 8px;
  font-size: calc(13px*var(--fs,1)); font-family: 'DM Sans', inherit;
  color: var(--sp-text);
  background: var(--sp-surface);
  transition: border-color .2s;
}
.spermio-app .form-textarea:focus {
  border-color: var(--sp-primary);
  outline: none;
  box-shadow: 0 0 0 3px var(--sp-primary-pale);
}

/* =============================================================================
   21. RESPONSIVE
   ============================================================================= */

@media (max-width: 768px) {
  .spermio-app .param-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }
  .spermio-app .grid-4 {
    grid-template-columns: 1fr 1fr;
  }
  .spermio-app .grid-2,
  .spermio-app .grid-3 {
    grid-template-columns: 1fr;
  }
  .spermio-app .section-tab {
    font-size: calc(9px*var(--fs,1)); padding: 7px 4px;
  }
  .spermio-app .stats-grid,
  .spermio-app .result-stats {
    flex-direction: column;
  }
  .spermio-app .images-grid {
    grid-template-columns: 1fr;
  }
  .spermio-app .card-body {
    padding: 12px 14px;
  }
  .spermio-app .cat-body {
    padding: 6px 8px;
  }
  .spermio-app .settings-param {
    flex-wrap: wrap;
  }
  .spermio-app .modal-box {
    width: 95%; padding: 16px;
  }
}
