/* ══════════════════════════════════════════════
   EqualRisk Studio — Foglio di stile principale
   ══════════════════════════════════════════════ */

:root {
    --sidebar-w:     260px;
    --topbar-h:       64px;
    --er-primary:    #1a3a5c;
    --er-primary-lt: #2c5282;
    --er-accent:     #2e7d32;
    --er-accent-lt:  #388e3c;
    --er-accent-soft:#e8f5e9;
    --er-danger:     #c62828;
    --er-bg:         #f4f6f9;
    --er-card-shadow:0 1px 4px rgba(0,0,0,.08), 0 2px 12px rgba(0,0,0,.04);
    --er-radius:     10px;
    --font-mono:     'Courier New', Courier, monospace;
}

/* ── Reset & base ── */
*, *::before, *::after { box-sizing: border-box; }
body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--er-bg);
    color: #1a202c;
    font-size: 0.92rem;
}

/* ══════════ SIDEBAR ══════════ */
.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    background: var(--er-primary);
    display: flex;
    flex-direction: column;
    z-index: 200;
    box-shadow: 2px 0 12px rgba(0,0,0,.15);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 20px 18px;
    border-bottom: 1px solid rgba(255,255,255,.1);
}

.brand-icon {
    width: 42px; height: 42px;
    background: var(--er-accent);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem;
    color: white;
    flex-shrink: 0;
}

.brand-name {
    color: white;
    font-weight: 700;
    font-size: .95rem;
    line-height: 1.2;
}

.brand-sub {
    color: rgba(255,255,255,.45);
    font-size: .72rem;
    margin-top: 2px;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 10px;
    overflow-y: auto;
}

.nav-section-label {
    color: rgba(255,255,255,.35);
    font-size: .68rem;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    padding: 0 10px 6px;
    margin-top: 4px;
}

.nav-link-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    color: rgba(255,255,255,.75);
    text-decoration: none;
    border-radius: 8px;
    margin-bottom: 2px;
    font-size: .88rem;
    transition: background .15s, color .15s;
}
.nav-link-item i { font-size: 1rem; width: 20px; flex-shrink: 0; }
.nav-link-item:hover { background: rgba(255,255,255,.1); color: white; }
.nav-link-item.active { background: var(--er-accent); color: white; }

.nav-divider {
    height: 1px;
    background: rgba(255,255,255,.08);
    margin: 10px 0;
}

.sidebar-saldo {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 12px 10px;
    padding: 10px 12px;
    background: rgba(255,255,255,.06);
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 8px;
    color: rgba(255,255,255,.85);
    text-decoration: none;
    font-size: .8rem;
    transition: background .15s, color .15s;
}
.sidebar-saldo:hover { background: rgba(255,255,255,.12); color: white; }
.sidebar-saldo i { font-size: 1rem; color: var(--er-accent-lt); }
.sidebar-saldo strong { color: white; }

.sidebar-footer {
    padding: 14px 20px;
    border-top: 1px solid rgba(255,255,255,.08);
    color: rgba(255,255,255,.35);
    font-size: .73rem;
    display: flex; gap: 6px; align-items: center;
}

.text-accent { color: var(--er-accent) !important; }

/* ══════════ MAIN WRAPPER ══════════ */
.main-wrapper {
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ── Topbar ── */
.topbar {
    position: sticky; top: 0; z-index: 100;
    background: white;
    border-bottom: 1px solid #e2e8f0;
    padding: 0 28px;
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.topbar-left { min-width: 0; }
.min-w-0 { min-width: 0; }

.page-heading {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--er-primary);
    margin: 0;
    line-height: 1.2;
}

.breadcrumb { margin: 2px 0 0; }
.breadcrumb-item a { color: var(--er-accent); text-decoration: none; }
.breadcrumb-item a:hover { text-decoration: underline; }

/* ── Content area ── */
.content-wrap {
    padding: 28px;
    flex: 1;
}

/* ══════════ CARDS ══════════ */
.er-card {
    background: white;
    border-radius: var(--er-radius);
    box-shadow: var(--er-card-shadow);
    overflow: hidden;
}

.er-card-header {
    padding: 16px 20px;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.er-card-title {
    margin: 0;
    font-size: .9rem;
    font-weight: 600;
    color: #1a202c;
    display: flex; align-items: center;
}

.er-card-body { padding: 20px; }

/* ══════════ STAT CARDS ══════════ */
.stat-card {
    background: white;
    border-radius: var(--er-radius);
    padding: 22px 20px;
    box-shadow: var(--er-card-shadow);
    display: flex;
    align-items: center;
    gap: 16px;
    border-left: 4px solid transparent;
}

.stat-primary { border-left-color: var(--er-primary); }
.stat-info    { border-left-color: #2b6cb0; }
.stat-success { border-left-color: var(--er-accent); }
.stat-warning { border-left-color: #c05621; }
.stat-purple  { border-left-color: #6b46c1; }

.stat-icon {
    font-size: 1.8rem;
    opacity: .25;
    flex-shrink: 0;
}

.stat-number {
    font-size: 2rem;
    font-weight: 800;
    line-height: 1;
    color: var(--er-primary);
}

.stat-label {
    font-size: .78rem;
    color: #718096;
    margin-top: 3px;
}

/* ══════════ MINI STATS ("il mese in breve") ══════════ */
.mini-stat {
    padding: 4px 0 4px 10px;
    border-left: 3px solid #e2e8f0;
    border-radius: 4px;
}
.mini-stat i {
    font-size: 1.1rem;
    color: var(--er-accent-lt);
}

/* Varianti colore del bordo sinistro, stessa palette di .stat-card */
.mini-stat-primary { border-left-color: var(--er-primary); }
.mini-stat-info     { border-left-color: #2b6cb0; }
.mini-stat-success { border-left-color: var(--er-accent); }
.mini-stat-warning { border-left-color: #c05621; }
.mini-stat-purple  { border-left-color: #6b46c1; }
.mini-stat-danger  { border-left-color: var(--er-danger); }
.mini-stat-number {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--er-primary);
    line-height: 1.2;
}
.mini-stat-label {
    font-size: .74rem;
    color: #718096;
}

/* ══════════ TABLES ══════════ */
.er-table { font-size: .86rem; }
.er-table th {
    background: #fafafa;
    font-weight: 600;
    color: #4a5568;
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    border-bottom: 2px solid #e2e8f0 !important;
    padding: 10px 16px !important;
    white-space: nowrap;
}
.er-table td {
    padding: 12px 16px !important;
    vertical-align: middle;
    border-bottom: 1px solid #f0f4f8;
}
.er-table tbody tr:hover { background: #f8fafc; }
.er-table tbody tr:last-child td { border-bottom: none; }

/* ── Table logo ── */
.table-logo {
    width: 32px; height: 32px;
    object-fit: contain;
    border-radius: 4px;
    border: 1px solid #e2e8f0;
}
.table-logo-placeholder {
    width: 32px; height: 32px;
    background: var(--er-primary);
    border-radius: 6px;
    color: white;
    font-size: .7rem;
    font-weight: 700;
    display: flex; align-items: center; justify-content: center;
}

/* ══════════ BUTTONS ══════════ */
.btn-er-primary {
    background: var(--er-accent);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 7px 18px;
    font-weight: 500;
    font-size: .88rem;
    transition: background .15s, box-shadow .15s;
}
.btn-er-primary:hover {
    background: var(--er-accent-lt);
    color: white;
    box-shadow: 0 2px 8px rgba(46,125,50,.3);
}
.btn-er-primary:active { background: #1b5e20; }

/* ══════════ FORMS ══════════ */
.form-label { font-weight: 500; font-size: .85rem; color: #2d3748; margin-bottom: 4px; }
.form-label.required::after {
    content: ' *';
    color: var(--er-danger);
}
.form-control, .form-select {
    border-radius: 7px;
    border: 1.5px solid #e2e8f0;
    font-size: .88rem;
    padding: 7px 12px;
    transition: border-color .15s, box-shadow .15s;
}
.form-control:focus, .form-select:focus {
    border-color: var(--er-accent);
    box-shadow: 0 0 0 3px rgba(46,125,50,.12);
    outline: none;
}
.form-text { font-size: .78rem; color: #718096; margin-top: 4px; }

/* Step badge */
.step-badge {
    display: inline-flex;
    width: 22px; height: 22px;
    background: var(--er-accent);
    color: white;
    border-radius: 50%;
    font-size: .75rem;
    font-weight: 700;
    align-items: center;
    justify-content: center;
    margin-right: 8px;
    flex-shrink: 0;
}

/* ── Figure blocks ── */
.figura-block {
    border: 1.5px solid #e8edf2;
    border-radius: 8px;
    overflow: hidden;
}
.figura-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    cursor: pointer;
    background: #fafbfc;
    user-select: none;
}
.figura-header:hover { background: #f0f4f8; }
.figura-label { font-weight: 600; font-size: .88rem; }
.figura-body { padding: 14px; background: white; border-top: 1px solid #e8edf2; }

/* ── Logo upload ── */
.logo-drop-zone {
    border: 2px dashed #cbd5e0;
    border-radius: 10px;
    padding: 28px 20px;
    text-align: center;
    cursor: pointer;
    transition: border-color .2s, background .2s;
    background: #fafbfc;
    min-height: 120px;
    display: flex; align-items: center; justify-content: center;
}
.logo-drop-zone:hover { border-color: var(--er-accent); background: var(--er-accent-soft); }
.logo-drop-zone.drag-over { border-color: var(--er-accent); background: var(--er-accent-soft); }
.logo-preview { max-height: 100px; max-width: 100%; object-fit: contain; }  /* 100%: a 200px sbordava dal riquadro nella colonna stretta */

/* ── Autocomplete ── */
.autocomplete-list {
    position: absolute;
    z-index: 500;
    background: white;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,.12);
    max-height: 240px;
    overflow-y: auto;
    width: 100%;
}
.autocomplete-item {
    padding: 8px 14px;
    cursor: pointer;
    font-size: .83rem;
    border-bottom: 1px solid #f0f0f0;
}
.autocomplete-item:hover { background: var(--er-accent-soft); }
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-list:empty { display: none; }

/* ══════════ BADGES ══════════ */
.badge-stato {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: .75rem;
    font-weight: 600;
}
.badge-bozza      { background: #edf2f7; color: #4a5568; }
.badge-in_corso   { background: #fffbeb; color: #92400e; border: 1px solid #fcd34d; }
.badge-da_approvare{ background: #eff6ff; color: #1e40af; border: 1px solid #93c5fd; }
.badge-approvata  { background: #f0fdf4; color: #166534; border: 1px solid #86efac; }

.dimensione-micro   { background: #f3f4f6; color: #374151; }
.dimensione-piccola { background: #eff6ff; color: #1e40af; }
.dimensione-media   { background: #f0fdf4; color: #166534; }
.dimensione-grande  { background: #fdf2f8; color: #86198f; }

.bg-er      { background-color: var(--er-accent) !important; }
.bg-er-soft { background-color: var(--er-accent-soft) !important; }
.text-er    { color: var(--er-accent) !important; }

/* ══════════ CLIENT DETAIL ══════════ */
.cliente-logo {
    max-height: 80px;
    max-width: 200px;
    object-fit: contain;
}
.cliente-logo-placeholder {
    width: 80px; height: 80px;
    background: var(--er-primary);
    border-radius: 14px;
    color: white;
    font-size: 1.5rem;
    font-weight: 700;
    display: inline-flex; align-items: center; justify-content: center;
}

.organico-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 12px; text-align: center; }
.organico-num  { font-size: 1.5rem; font-weight: 700; color: var(--er-primary); }
.organico-label{ font-size: .75rem; color: #718096; }

.info-list { display: flex; flex-direction: column; gap: 10px; margin: 0; }
.info-row  { display: flex; gap: 12px; align-items: flex-start; }
.info-row dt { color: #a0aec0; font-weight: normal; min-width: 20px; flex-shrink: 0; }
.info-row dd { margin: 0; }

.figura-card {
    display: flex; gap: 12px; align-items: flex-start;
    background: #fafbfc;
    border: 1.5px solid #e8edf2;
    border-radius: 8px;
    padding: 12px 14px;
}
.figura-icon  { font-size: 1.3rem; flex-shrink: 0; }
.figura-ruolo { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.figura-nome  { font-weight: 600; font-size: .9rem; }
.figura-qualifica { font-size: .78rem; }

/* ══════════ ACTIVITY LOG ══════════ */
.activity-list { list-style: none; margin: 0; padding: 0; }
.activity-item {
    display: flex; gap: 10px; align-items: flex-start;
    padding: 10px 16px;
    border-bottom: 1px solid #f0f4f8;
}
.activity-item:last-child { border-bottom: none; }
.activity-icon {
    width: 28px; height: 28px;
    background: var(--er-accent-soft);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: var(--er-accent);
    font-size: .85rem;
    flex-shrink: 0;
}
.activity-desc { font-size: .83rem; }
.activity-time { font-size: .75rem; }

/* ══════════ NORM BADGES ══════════ */
.norm-badge {
    background: #fafbfc;
    border: 1.5px solid #e8edf2;
    border-radius: 8px;
    padding: 14px 16px;
    height: 100%;
}
.norm-code  { font-family: var(--font-mono); font-size: .78rem; color: var(--er-accent); font-weight: 700; }
.norm-title { font-weight: 600; font-size: .88rem; margin: 4px 0; }
.norm-desc  { font-size: .8rem; color: #718096; line-height: 1.5; }

/* ══════════ EMPTY STATE ══════════ */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #a0aec0;
}
.empty-state i { font-size: 2.5rem; display: block; margin-bottom: 12px; }
.empty-state p { margin-bottom: 16px; font-size: .9rem; }

/* ══════════ ROADMAP ══════════ */
.roadmap-list { list-style: none; margin: 0; padding: 0; }
.roadmap-list li {
    display: flex; gap: 10px; align-items: center;
    padding: 10px 16px;
    border-bottom: 1px solid #f0f4f8;
    font-size: .83rem;
}
.roadmap-list li:last-child { border-bottom: none; }
.roadmap-done { color: #1a202c; }
.roadmap-next { color: #a0aec0; }

/* ══════════ SETTINGS ══════════ */
.font-mono { font-family: var(--font-mono); letter-spacing: .04em; }

/* ══════════ UTILITIES ══════════ */
.sticky-top { position: sticky; }

/* ══════════════════════════════════════════════
   FASE 2 — Checklist DVR, Matrici, Gauge
   ══════════════════════════════════════════════ */

/* ── DVR Progress bar ── */
.dvr-progress {
  display: flex;
  align-items: center;
  background: white;
  border-radius: var(--er-radius);
  padding: 16px 24px;
  box-shadow: var(--er-card-shadow);
}
.dvr-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.dvr-step-circle {
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 2px solid #e2e8f0;
  background: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  color: #a0aec0;
  transition: all .2s;
}
.dvr-step.done .dvr-step-circle {
  background: var(--er-accent);
  border-color: var(--er-accent);
  color: white;
}
.dvr-step.active .dvr-step-circle {
  border-color: var(--er-accent);
  color: var(--er-accent);
  box-shadow: 0 0 0 3px rgba(46,125,50,.15);
}
.dvr-step-label {
  font-size: .75rem;
  font-weight: 600;
  color: #a0aec0;
}
.dvr-step.done.active .dvr-step-circle { color: white; }
.dvr-step.done .dvr-step-label,
.dvr-step.active .dvr-step-label { color: var(--er-accent); }
.dvr-step-line {
  flex: 1;
  min-width: 8px;
  height: 2px;
  background: #e2e8f0;
  margin: 0 8px;
  margin-bottom: 22px;
}
/* D18 (30/09/2026): i passi sono link */
a.dvr-step { text-decoration: none; }
a.dvr-step:hover .dvr-step-circle { border-color: var(--er-accent); color: var(--er-accent); }
a.dvr-step.done:hover .dvr-step-circle { color: white; filter: brightness(1.1); }
a.dvr-step:hover .dvr-step-label { color: var(--er-accent); }
.dvr-step.locked { cursor: not-allowed; opacity: .6; }

/* ── Step cards (hub valutazione) ── */
.step-card {
  background: white;
  border-radius: var(--er-radius);
  padding: 20px;
  box-shadow: var(--er-card-shadow);
  border: 2px solid #e2e8f0;
  transition: border-color .2s;
  height: 100%;
}
.step-card.step-done   { border-color: var(--er-accent); }
.step-card.step-available:hover { border-color: var(--er-accent); }
.step-card.step-locked { opacity: .6; }
.step-icon { font-size: 1.8rem; margin-bottom: 10px; color: var(--er-primary); }
.step-card.step-done .step-icon { color: var(--er-accent); }
.step-title { font-weight: 700; font-size: .95rem; margin-bottom: 4px; }
.step-desc { line-height: 1.4; }

/* ── Legenda checklist ── */
.legenda-item {
  padding: 8px 12px;
  border-radius: 8px;
  border: 1.5px solid transparent;
}
.legenda-valore {
  font-size: 1.3rem;
  font-weight: 800;
  margin-bottom: 2px;
}
.legenda-label { font-size: .72rem; line-height: 1.3; }
.legenda-success { background: #e8f5e9; color: #1b5e20; border-color: #a5d6a7; }
.legenda-info    { background: #e3f2fd; color: #0d47a1; border-color: #90caf9; }
.legenda-warning { background: #fffde7; color: #e65100; border-color: #ffd54f; }
.legenda-danger  { background: #ffebee; color: #b71c1c; border-color: #ef9a9a; }

/* ── Domande checklist ── */
.domanda-row { padding: 18px 20px; }
.domanda-header {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 12px;
}
.domanda-num {
  width: 26px; height: 26px;
  background: var(--er-primary);
  color: white;
  border-radius: 50%;
  font-size: .75rem;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}
.domanda-testo { flex: 1; font-size: .88rem; }
.domanda-stato { flex-shrink: 0; font-size: 1.1rem; }

.domanda-opzioni {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-left: 38px;
}

.opzione-label {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border: 1.5px solid #e2e8f0;
  border-radius: 8px;
  cursor: pointer;
  transition: all .15s;
  background: white;
}
.opzione-label:hover { border-color: #a0aec0; background: #f8fafc; }
.opzione-label.selected { border-color: var(--er-accent); background: var(--er-accent-soft); }
.opzione-radio { display: none; }

.opzione-badge {
  width: 26px; height: 26px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800;
  font-size: .8rem;
  flex-shrink: 0;
}
.opzione-badge.v0 { background: #e8f5e9; color: #1b5e20; }
.opzione-badge.v1 { background: #e3f2fd; color: #0d47a1; }
.opzione-badge.v2 { background: #fffde7; color: #e65100; }
.opzione-badge.v3 { background: #ffebee; color: #b71c1c; }

.opzione-label.selected .opzione-badge.v0 { background: #2e7d32; color: white; }
.opzione-label.selected .opzione-badge.v1 { background: #1565c0; color: white; }
.opzione-label.selected .opzione-badge.v2 { background: #e65100; color: white; }
.opzione-label.selected .opzione-badge.v3 { background: #b71c1c; color: white; }
/* "Non applicabile" (06/09/2026): esclusa dal calcolo, segnalata al modello IA */
.opzione-badge.vna { background: #eceff1; color: #546e7a; font-size: .68rem; letter-spacing: .02em; }
.opzione-label.selected .opzione-badge.vna { background: #546e7a; color: white; }
.opzione-label.opzione-na { border-style: dashed; }
.domanda-nota { padding: .5rem 1rem .9rem 3.25rem; margin-top: .25rem; border-top: 1px dashed #e2e8f0; }
.domanda-nota .form-control, .domanda-nota .input-group-text { font-size: .82rem; }
.domanda-nota .input-group-text { background: #f8fafc; }

.opzione-testo { font-size: .83rem; line-height: 1.3; }

/* ── Rischio mini card (hub) ── */
.rischio-mini-card {
  border-radius: 8px;
  padding: 14px 16px;
  border-left: 4px solid transparent;
}

/* ── Gruppo riga risultati ── */
.gruppo-riga { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-bottom: 1px solid #f0f4f8; }
.gruppo-riga:last-child { border-bottom: none; }
.rischio-bar-wrap { flex: 1; min-width: 0; }


/* Step num badge (dettaglio DVR) */
.step-num-badge {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 2px solid #e2e8f0;
  background: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .85rem;
  color: #a0aec0;
  flex-shrink: 0;
}
.step-num-badge.done { background: var(--er-accent); border-color: var(--er-accent); color: white; }
.step-num-badge.next { border-color: var(--er-accent); color: var(--er-accent);
  box-shadow: 0 0 0 3px rgba(46,125,50,.15); }
.step-card.step-next { border-color: var(--er-accent);
  box-shadow: 0 2px 12px rgba(46,125,50,.12); }


/* ── Quill Rich Text Editor ── */
.quill-wrapper {
    border: 1.5px solid #e2e8f0;
    border-radius: 7px;
    overflow: hidden;
    transition: border-color .15s;
}
.quill-wrapper:focus-within {
    border-color: var(--er-accent);
    box-shadow: 0 0 0 3px rgba(46,125,50,.12);
}
.ql-toolbar.ql-snow {
    border: none;
    border-bottom: 1px solid #e2e8f0 !important;
    background: #fafbfc;
    padding: 6px 8px;
}
.ql-container.ql-snow {
    border: none !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: .9rem;
}
.ql-editor {
    padding: 10px 12px;
    min-height: 120px;
}
.ql-editor.ql-blank::before {
    color: #a0aec0;
    font-style: normal;
}


/* ── Er-textarea (editor testi) ── */
.er-textarea-wrap { position: relative; }
.er-textarea {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: .9rem;
    line-height: 1.6;
    resize: vertical;
    min-height: 120px;
    border: 1.5px solid #e2e8f0;
    border-radius: 7px;
    padding: 10px 14px;
    width: 100%;
    transition: border-color .15s, box-shadow .15s;
    overflow: hidden;
}
.er-textarea:focus {
    border-color: var(--er-accent);
    box-shadow: 0 0 0 3px rgba(46,125,50,.12);
    outline: none;
    overflow-y: auto;
}

/* ── Quill wrap (nuovo) ── */
.quill-wrap {
    border: 1.5px solid #e2e8f0;
    border-radius: 7px;
    overflow: hidden;
    transition: border-color .15s, box-shadow .15s;
    margin-bottom: 4px;
    background: white;
}
.quill-wrap:focus-within {
    border-color: var(--er-accent);
    box-shadow: 0 0 0 3px rgba(46,125,50,.12);
}
.quill-wrap .ql-toolbar.ql-snow {
    border: none !important;
    border-bottom: 1px solid #e2e8f0 !important;
    background: #fafbfc;
    padding: 5px 8px;
}
.quill-wrap .ql-container.ql-snow {
    border: none !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: .9rem;
    line-height: 1.6;
}
.quill-wrap .ql-editor {
    min-height: 120px;
    padding: 10px 12px;
}
.quill-wrap .ql-editor.ql-blank::before {
    color: #a0aec0;
    font-style: normal;
}

/* ── Piano di azione editabile ── */
.misura-row { border-bottom: 2px solid #e2e8f0; transition: background .15s; }
.misura-row:hover { background: #fafbfc; }
.misura-row:last-child { border-bottom: none; }
.misura-num {
    width: 28px; height: 28px; border-radius: 50%;
    background: var(--er-primary); color: white;
    font-size: .8rem; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; margin-top: 2px;
}

/* ── Avviso invio non riuscito per problemi di connessione ──
   Sovrapposto al lavoro in corso invece della pagina di errore nativa
   del browser: chiudendolo, i dati compilati restano intatti. */
.rete-overlay-backdrop {
    position: fixed; inset: 0; z-index: 2000;
    background: rgba(15, 23, 42, .55);
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
}
.rete-overlay-card {
    background: white;
    border-radius: var(--er-radius);
    box-shadow: 0 8px 32px rgba(0,0,0,.25);
    max-width: 460px;
    width: 100%;
    padding: 28px 26px;
}
.rete-overlay-card h5 {
    display: flex; align-items: center; gap: 10px;
    color: var(--er-primary);
    font-weight: 700;
    margin-bottom: 12px;
}
.rete-overlay-card p {
    color: #4a5568;
    margin-bottom: 20px;
}

/* Stato dei ritentativi di rete (erStatoRete in app.js, 21/09/2026) */
.rete-stato {
    position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
    z-index: 2100;
    background: #1f2937; color: #fff;
    padding: 10px 18px; border-radius: 999px;
    font-size: .9rem;
    box-shadow: 0 6px 20px rgba(0,0,0,.3);
}

/* ══════════ SCHERMI STRETTI (D23, 30/09/2026) ══════════
   Sotto i 992 px la barra laterale non occupa più spazio: si apre con il
   pulsante ☰ della testata e si chiude toccando fuori o con Esc. */
.btn-menu-laterale {
    display: none;
    border: 1px solid #e2e8f0;
    background: white;
    border-radius: 8px;
    width: 38px; height: 38px;
    align-items: center; justify-content: center;
    font-size: 1.3rem;
    color: var(--er-primary);
    flex-shrink: 0;
}
.sidebar-velo { display: none; }

@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform .2s ease;
        box-shadow: none;
    }
    body.sidebar-aperta .sidebar { transform: none; box-shadow: 2px 0 12px rgba(0,0,0,.25); }
    body.sidebar-aperta .sidebar-velo {
        display: block;
        position: fixed; inset: 0;
        background: rgba(0,0,0,.4);
        z-index: 150;
    }
    .main-wrapper { margin-left: 0; }
    .btn-menu-laterale { display: inline-flex; }
    .topbar {
        height: auto;
        min-height: var(--topbar-h);
        padding: 10px 16px;
        flex-wrap: wrap;
        gap: 8px 12px;
    }
    .topbar-left { display: flex; align-items: center; gap: 12px; flex: 1 1 auto; }
    .topbar-right { flex-wrap: wrap; max-width: 100%; }
    .topbar-right > * { flex-wrap: wrap; max-width: 100%; }
    .topbar-right .badge { white-space: normal; text-align: left; }
    .content-wrap { padding: 16px; }
}

@media (max-width: 767.98px) {
    .dvr-progress { padding: 12px; overflow-x: auto; }
    .dvr-step-circle { width: 30px; height: 30px; font-size: .85rem; }
    .dvr-step-label { display: none; }
    .dvr-step-line { margin: 0 4px; }
}
