/* RESET E FONT */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f3f4f6;
    color: #1f2937;
}

/* HEADER CON GRIGLIA A 3 COLONNE: I TAB IN CENTRO NON SI SPOSTANO MAI! */
.app-header {
    background: #111827;
    color: #fff;
    padding: 12px 24px;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    justify-self: start;
}

.brand-badge {
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 1.3rem;
    font-weight: bold;
    letter-spacing: 2px;
    border: 1px solid #fff;
    padding: 2px 10px;
}

.app-header h1 {
    font-size: 1.1rem;
    font-weight: 500;
}

.main-nav-tabs {
    justify-self: center;
}

.header-actions {
    display: flex;
    gap: 10px;
    justify-self: end;
}

/* BOTTONI */
.btn {
    padding: 8px 16px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
}

.btn-primary { background: #2563eb; color: white; }
.btn-primary:hover { background: #1d4ed8; }
.btn-secondary { background: #374151; color: white; }
.btn-ai { background: #7c3aed; color: white; }
.btn-outline { border: 1px solid #9ca3af; background: white; color: #374151; }
.btn-small { background: #10b981; color: white; padding: 5px 10px; font-size: 0.8rem; }
.btn-remove { background: #ef4444; color: white; border: none; border-radius: 4px; padding: 4px 8px; cursor: pointer; }

/* LAYOUT SCHERMO DIVISO */
.workspace {
    display: grid;
    grid-template-columns: 1fr 1.15fr;
    gap: 20px;
    padding: 20px;
    align-items: start;
}

/* PANNELLO EDITOR (SINISTRA) */
.card {
    background: white;
    border-radius: 8px;
    padding: 18px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}

.ai-box {
    border-left: 4px solid #7c3aed;
}

.card h2 {
    font-size: 1.05rem;
    margin-bottom: 8px;
    color: #111827;
}

.hint {
    font-size: 0.85rem;
    color: #6b7280;
    margin-bottom: 12px;
}

label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    margin-bottom: 4px;
    margin-top: 10px;
    color: #374151;
}

input[type="text"],
input[type="number"],
select,
textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #d1d5db;
    border-radius: 5px;
    font-size: 0.9rem;
    font-family: inherit;
}

.readonly-input {
    background-color: #f3f4f6;
    font-weight: bold;
}

.form-row {
    display: flex;
    gap: 12px;
}

.form-group { flex: 1; }
.flex-2 { flex: 2; }
.flex-1 { flex: 1; }

.ai-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 14px;
    margin-bottom: 8px;
}

.ing-row-editor {
    display: flex;
    gap: 8px;
    margin-bottom: 6px;
}

.ing-row-editor .ing-qty { width: 90px; }
.ing-row-editor .ing-unit { width: 70px; }
.ing-row-editor .ing-name { flex: 1; }

.allergeni-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    margin-top: 6px;
    background: #f9fafb;
    padding: 10px;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
}

.allergene-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
    font-weight: normal;
    margin: 0;
    cursor: pointer;
}

/* ==========================================================
   STILE FOGLIO SCHEDA TECNICA "DAMA" (COLONNA DESTRA + PDF)
   ========================================================== */
.preview-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.dama-sheet {
    width: 100%;
    max-width: 210mm;
    min-height: 297mm;
    background: white;
    padding: 10mm 12mm;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    font-family: 'Times New Roman', Times, Georgia, serif;
    font-variant-numeric: lining-nums tabular-nums; /* Numeri tutti alti e larghi uguali! */
    color: #111;
    display: flex;
    flex-direction: column;
}

/* Intestazione */
.dama-header {
    display: flex;
    justify-content: space-between;
    align-items: stretch;
    gap: 14px;
    margin-bottom: 8px;
}

.dama-logo-box {
    width: 38%;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 4px;
}

.dama-logo-img {
    max-width: 100%;
    max-height: 28mm; /* Mantiene il logo in squadra col box Nome Prodotto */
    object-fit: contain;
}

.dama-logo-title {
    font-size: 2.5rem;
    letter-spacing: 4px;
    font-weight: normal;
    border-bottom: 1px solid #333;
    padding-bottom: 2px;
    margin-bottom: 3px;
}

.dama-logo-sub {
    font-size: 0.72rem;
    font-style: italic;
    letter-spacing: 1px;
}

.dama-product-box {
    width: 64%;
    border: 1px solid #222;
    padding: 6px 12px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
}

.dama-box-label {
    font-size: 0.85rem;
    letter-spacing: 1px;
    margin-bottom: 4px;
}

.dama-product-title {
    font-size: 1.2rem;
    font-weight: bold;
    text-transform: uppercase;
}

/* Strisce Orizzontali Titoli Sezione */
.dama-banner {
    border: 1px solid #222;
    text-align: center;
    padding: 3px 0;
    font-size: 0.9rem;
    letter-spacing: 1.5px;
    margin-top: 8px;
    margin-bottom: 5px;
    background: #fff;
}

/* Elementi di Comunicazione */
.dama-comm-box {
    border: 1px solid #222;
    min-height: 24mm;
    padding: 6px 10px;
}

.dama-comm-sub {
    text-align: center;
    font-size: 0.8rem;
    margin-bottom: 6px;
    color: #333;
}

.dama-comm-content {
    font-size: 0.88rem;
    line-height: 1.4;
    white-space: pre-wrap;
}

/* Tabella Pesi */
.dama-weights-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 5px 14px;
    margin-bottom: 4px;
}

.weight-cell {
    border: 1px solid #222;
    padding: 4px 10px;
    display: grid;
    grid-template-columns: 1fr auto 26px; /* Etichetta | Numero incolonnato | Unità Gr */
    align-items: baseline;
    gap: 8px;
    font-size: 0.88rem;
}

.weight-val {
    font-weight: bold;
    text-align: right;
}

.weight-unit {
    text-align: right;
}

/* Griglia Ingredienti a 2 Colonne (Solo le coppie necessarie) */
.dama-ingredients-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px 14px;
    margin-bottom: 4px;
}

.dama-ing-cell {
    display: flex;
    border: 1px solid #222;
    min-height: 26px;
    font-size: 0.86rem;
}

/* Anche nelle celle ingredienti allineiamo numero e unità alla perfezione */
.dama-ing-qty {
    width: 76px;
    border-right: 1px solid #222;
    padding: 3px 6px;
    display: flex;
    justify-content: flex-end;
    align-items: baseline;
    gap: 4px;
    font-weight: bold;
    flex-shrink: 0;
}

.dama-ing-name {
    padding: 3px 8px;
    flex: 1;
}

/* Sostituisci .dama-proc-box con questo (SENZA white-space: pre-wrap!) */
.dama-proc-box {
    flex: 1;
    font-size: 0.92rem;
    line-height: 26px;
    min-height: 78px;
    padding: 0 6px;
    background-image: repeating-linear-gradient(transparent, transparent 25px, #bbb 26px);
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
}

/* Box Note */
.dama-notes-box {
    border: 1px solid #222;
    min-height: 22mm;
    padding: 6px 10px;
    margin-top: 10px;
    page-break-inside: avoid;
}

.notes-label {
    font-size: 0.85rem;
    font-weight: bold;
    margin-bottom: 3px;
}

.notes-content {
    font-size: 0.88rem;
    white-space: pre-wrap;
    line-height: 1.35;
}

/* Striscia Allergeni */
.dama-allergeni-box {
    margin-top: 8px;
    border: 1px solid #222;
    padding: 5px 10px;
    font-size: 0.82rem;
    page-break-inside: avoid;
}

.allergeni-title {
    font-weight: bold;
    margin-right: 6px;
}

/* SELETTORE BASE vs PIATTO */
.tipo-scheda-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
    margin-top: 8px;
}

.radio-card {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px;
    border: 2px solid #e5e7eb;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.88rem;
    margin: 0;
    background: #f9fafb;
}

.radio-card:has(input:checked) {
    border-color: #2563eb;
    background: #eff6ff;
    color: #1d4ed8;
}

/* BOX PESI E LUCCHETTO */
.weights-editor-box {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 10px 12px;
    margin-top: 12px;
}

.weights-editor-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-size: 0.82rem;
    font-weight: 700;
    color: #334155;
    margin-bottom: 4px;
}

.weights-editor-header small {
    font-weight: normal;
    color: #64748b;
    font-size: 0.76rem;
}

.input-with-lock {
    display: flex;
    gap: 4px;
}

.btn-lock {
    background: #e2e8f0;
    border: 1px solid #cbd5e1;
    border-radius: 5px;
    padding: 0 8px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.15s;
}

.btn-lock.locked {
    background: #fef08a;
    border-color: #eab308;
    box-shadow: inset 0 0 4px rgba(234,179,8,0.4);
}

/* ATTREZZATURE AUTOCOMPLETE E TAGS */
.attrezzature-input-row {
    display: flex;
    gap: 8px;
}

.tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.tag-badge {
    background: #e0f2fe;
    color: #0369a1;
    border: 1px solid #bae6fd;
    padding: 4px 10px;
    border-radius: 16px;
    font-size: 0.82rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.tag-badge button {
    background: none;
    border: none;
    color: #0369a1;
    font-weight: bold;
    cursor: pointer;
    font-size: 0.85rem;
}

/* FOOTER METADATI SCHEDA DAMA (ATTREZZATURE + ALLERGENI) */
.dama-footer-meta {
    margin-top: 8px;
    border: 1px solid #222;
    page-break-inside: avoid;
}

.dama-meta-row {
    padding: 5px 10px;
    font-size: 0.82rem;
    border-bottom: 1px solid #222;
}

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

.meta-title {
    font-weight: bold;
    margin-right: 6px;
}

.btn-success { background: #059669; color: white; }
.btn-success:hover { background: #047857; }
.section-actions { display: flex; gap: 6px; }

/* Card Sotto-Preparazione nell'Editor a sinistra */
.gruppo-editor-card {
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 10px;
    margin-bottom: 12px;
    background: #f8fafc;
}

.gruppo-editor-header {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px dashed #cbd5e1;
}

.gruppo-editor-header .inp-titolo-gruppo {
    flex: 1;
    font-weight: bold;
    background: #fff;
}

.scala-gruppo-box {
    display: flex;
    align-items: center;
    gap: 4px;
    background: #e0e7ff;
    padding: 3px 8px;
    border-radius: 5px;
    font-size: 0.78rem;
    font-weight: 600;
    color: #1e40af;
}

.scala-gruppo-box input {
    width: 62px !important;
    padding: 3px 5px !important;
    text-align: right;
    font-weight: bold;
}

/* Finestrella scelta Base da importare */
.import-basi-dropdown {
    background: #fff;
    border: 2px solid #2563eb;
    border-radius: 6px;
    padding: 10px;
    margin-bottom: 12px;
}

.base-item-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 8px;
    border-bottom: 1px solid #f1f5f9;
    font-size: 0.85rem;
}

/* Stile Sotto-Preparazioni su 2 Colonne nel Foglio A4 DAMA */
.dama-subgroups-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 14px;
    margin-bottom: 6px;
    align-items: start;
}

.dama-subgroup-title {
    font-weight: bold;
    font-size: 0.88rem;
    margin-bottom: 4px;
    padding-left: 2px;
}

.dama-subgroup-cells {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* Stile Procedimento a Blocchi: zero righe vuote sotto il titolo, 1 riga tra due blocchi diversi */
.dama-proc-block {
    margin-bottom: 26px; /* Lascia esattamente 1 riga vuota tra una preparazione e la successiva */
}

.dama-proc-block:last-child {
    margin-bottom: 0;
}

.dama-proc-title {
    font-weight: bold;
    text-decoration: underline;
    font-size: 0.92rem;
    line-height: 26px;
    margin: 0;
}

.dama-proc-list {
    margin: 0;
    padding-left: 20px;
    list-style-type: disc;
}

.dama-proc-list li {
    line-height: 26px;
    margin: 0;
}

/* Barra di ricerca dentro Importa Basi */
.import-basi-filters {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.import-basi-list {
    max-height: 200px;
    overflow-y: auto;
    border-top: 1px solid #e2e8f0;
}

/* FISARMONICA (ACCORDION) PER BOX AI E SOTTO-PREPARAZIONI */
.accordion-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.accordion-header h2 {
    margin: 0 !important;
}

.accordion-arrow {
    font-size: 0.85rem;
    color: #6b7280;
    transition: transform 0.2s ease;
    padding: 4px 8px;
    background: #f3f4f6;
    border-radius: 4px;
}

.accordion-collapsed .accordion-body {
    display: none;
}

/* TEMA DINAMICO CARD PRINCIPALE: BASE (AMBRA) vs PIATTO (BLU) */
.form-top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.mode-badge {
    font-size: 0.78rem;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 12px;
}

.mode-piatto {
    background: #dbeafe;
    color: #1e40af;
}

.mode-base {
    background: #fef3c7;
    color: #b45309;
}

.form-box.tema-base {
    border-top: 4px solid #f59e0b;
}

.form-box.tema-piatto {
    border-top: 4px solid #2563eb;
}

.radio-base-card:has(input:checked) {
    border-color: #f59e0b !important;
    background: #fffbeb !important;
    color: #b45309 !important;
}

/* COLORI DISTINTIVI PER LE SOTTO-PREPARAZIONI E FISARMONICA */
.gruppo-editor-card {
    border-left-width: 5px;
    transition: all 0.15s ease;
}

.gruppo-color-0 { border-left-color: #2563eb; } /* Blu */
.gruppo-color-1 { border-left-color: #059669; } /* Verde Smeraldo */
.gruppo-color-2 { border-left-color: #7c3aed; } /* Viola */
.gruppo-color-3 { border-left-color: #d97706; } /* Ambra */

.gruppo-toggle-btn {
    background: #e2e8f0;
    border: none;
    border-radius: 4px;
    width: 28px;
    height: 28px;
    cursor: pointer;
    font-size: 0.78rem;
    font-weight: bold;
    color: #334155;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.gruppo-toggle-btn:hover {
    background: #cbd5e1;
}

.gruppo-proc-integrato {
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px dashed #cbd5e1;
}

.assemblaggio-card {
    border-left: 5px solid #0f172a;
    background: #f1f5f9;
}

/* STATO VISIVO LUCCHETTO PESO PER PAX vs N. PAX */
.input-locked-gold {
    background-color: #fef9c3 !important;
    border-color: #eab308 !important;
    color: #854d0e !important;
    font-weight: bold;
}

.input-active-blue {
    border: 2px solid #2563eb !important;
    background-color: #eff6ff !important;
    font-weight: bold;
}

/* TAB NAVIGAZIONE HEADER */
.main-nav-tabs {
    display: flex;
    background: #1f2937;
    padding: 4px;
    border-radius: 8px;
    gap: 6px;
}

.nav-tab {
    background: transparent;
    color: #9ca3af;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.15s;
}

.nav-tab:hover {
    color: #fff;
}

.nav-tab.active {
    background: #2563eb;
    color: #fff;
}

/* WORKSPACE ARCHIVIO & RICERCA */
.archivio-workspace {
    max-width: 1350px;
    margin: 0 auto;
    padding: 20px;
}

.archivio-search-top {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.search-input-wrapper {
    flex: 2;
    min-width: 260px;
}

.search-input-wrapper input {
    font-size: 0.95rem;
    padding: 10px 14px;
    border: 2px solid #cbd5e1;
}

.search-input-wrapper input:focus {
    border-color: #2563eb;
    outline: none;
}

.tipo-filter-pills {
    display: flex;
    background: #f1f5f9;
    padding: 4px;
    border-radius: 6px;
    gap: 4px;
}

.pill-btn {
    border: none;
    background: transparent;
    padding: 6px 12px;
    border-radius: 5px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #475569;
    cursor: pointer;
}

.pill-btn.active {
    background: #fff;
    color: #1e40af;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.arch-cat-select {
    width: auto !important;
    min-width: 200px;
}

/* Barra Esclusione Allergeni */
.archivio-allergeni-bar {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.allergeni-filter-label {
    font-size: 0.8rem;
    font-weight: 700;
    color: #dc2626;
}

.allergeni-pills-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.allergene-exclude-pill {
    font-size: 0.76rem;
    padding: 4px 10px;
    border-radius: 14px;
    border: 1px solid #cbd5e1;
    background: #f8fafc;
    color: #475569;
    cursor: pointer;
    user-select: none;
}

.allergene-exclude-pill.excluded {
    background: #fee2e2;
    border-color: #ef4444;
    color: #b91c1c;
    font-weight: 700;
    text-decoration: line-through;
}

/* CARTELLE STILE GOOGLE DRIVE */
.arch-section-title {
    font-size: 1rem;
    color: #334155;
    margin-bottom: 12px;
}

.folders-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 12px;
}

.folder-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    transition: all 0.15s;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

.folder-card:hover {
    border-color: #2563eb;
    background: #f8fafc;
    transform: translateY(-2px);
}

.folder-info {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 0.9rem;
    color: #1e293b;
}

.folder-count {
    background: #e2e8f0;
    color: #475569;
    font-size: 0.78rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 12px;
}

.folder-breadcrumb {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.folder-active-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #1e40af;
}

/* CARD DELLE SCHEDE NEI RISULTATI */
.schede-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}

.scheda-archivio-card {
    background: #fff;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    border-top: 4px solid #2563eb;
    padding: 16px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.scheda-archivio-card.is-base {
    border-top-color: #f59e0b;
}

.scheda-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 8px;
}

.scheda-card-title {
    font-size: 1.02rem;
    font-weight: 700;
    color: #111827;
}

.scheda-card-meta {
    font-size: 0.82rem;
    color: #64748b;
    margin-bottom: 10px;
    line-height: 1.4;
}

.scheda-card-actions {
    display: flex;
    gap: 6px;
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid #f1f5f9;
}

/* Modalità "Solo Lettura / Anteprima Pulita A4" quando clicca "Apri PDF" dall'Archivio */
body.preview-only-mode .editor-panel {
    display: none !important;
}

body.preview-only-mode .workspace {
    display: flex;
    justify-content: center;
}

.preview-mode-banner {
    background: #1e40af;
    color: #fff;
    padding: 10px 20px;
    border-radius: 8px;
    margin-bottom: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 210mm;
}

/* SELETTORE INTERNO: FORMAT vs CORSI */
.sub-view-switcher {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-bottom: 20px;
}

.sub-switch-btn {
    padding: 10px 24px;
    border-radius: 8px;
    border: 2px solid #cbd5e1;
    background: #fff;
    font-size: 0.95rem;
    font-weight: 700;
    color: #475569;
    cursor: pointer;
    transition: all 0.15s;
}

.sub-switch-btn.active {
    border-color: #2563eb;
    background: #eff6ff;
    color: #1d4ed8;
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.15);
}

/* LAYOUT A 3 COLONNE PER LA GESTIONE FORMAT */
.format-workspace-grid {
    display: grid;
    grid-template-columns: 0.9fr 1.3fr 1.1fr;
    gap: 18px;
    align-items: start;
}

/* Colonna 1: Lista Format salvati */
.format-list-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
}

.format-list-item {
    border: 1px solid #e2e8f0;
    border-left: 4px solid #94a3b8;
    border-radius: 6px;
    padding: 10px 12px;
    background: #f8fafc;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.15s;
}

.format-list-item:hover {
    background: #f1f5f9;
}

.format-list-item.active {
    border-color: #2563eb;
    border-left: 5px solid #2563eb;
    background: #eff6ff;
}

/* Colonna 2: Schede incluse nel Format attivo */
.fmt-included-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
    min-height: 120px;
    background: #f8fafc;
    padding: 10px;
    border-radius: 6px;
    border: 1px dashed #cbd5e1;
}

.fmt-scheda-row {
    background: #fff;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 8px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.fmt-row-actions {
    display: flex;
    gap: 4px;
    align-items: center;
}

.btn-move {
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    padding: 2px 6px;
    cursor: pointer;
    font-size: 0.75rem;
}

.btn-move:hover {
    background: #e2e8f0;
}

/* Colonna 3: Picker Ricerca Schede da aggiungere */
.fmt-picker-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 460px;
    overflow-y: auto;
    padding-right: 4px;
}

.fmt-picker-item {
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 8px 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fff;
    font-size: 0.85rem;
}

.fmt-picker-item.already-in {
    background: #f0fdf4;
    border-color: #bbf7d0;
}

/* LAYOUT COMPOSITORE CORSI (2 COLONNE: EDITOR A SINISTRA, FOGLIO A4 SPESA A DESTRA) */
.corsi-workspace-grid {
    display: grid;
    grid-template-columns: 1fr 1.15fr;
    gap: 20px;
    align-items: start;
}

.corsi-right-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.moltiplicatore-box {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.8rem;
    font-weight: 700;
    color: #1e40af;
    background: #e0e7ff;
    padding: 3px 8px;
    border-radius: 5px;
}

.moltiplicatore-box input {
    width: 55px !important;
    padding: 2px 4px !important;
    text-align: center;
    font-weight: bold;
}

.crs-attr-checklist {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px 16px;
    font-size: 0.88rem;
    padding: 4px 2px;
}

/* BARRA BOTTONCINI FILTRO 3° LIVELLO (SOTTO-CATEGORIE) */
.subcat-tags-bar {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    padding: 10px 14px;
    margin-top: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.subcat-tags-label {
    font-size: 0.82rem;
    font-weight: 700;
    color: #1e40af;
}

.subcat-pills-container {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.subcat-pill {
    background: #fff;
    border: 1px solid #93c5fd;
    color: #1e3a8a;
    padding: 5px 12px;
    border-radius: 16px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}

.subcat-pill:hover {
    background: #dbeafe;
}

.subcat-pill.active {
    background: #2563eb;
    border-color: #1d4ed8;
    color: #fff;
}

/* CONTENITORI CON SCORRIMENTO INTERNO (ANTI-ALLUNGAMENTO PAGINA) */
.scrollable-box {
    max-height: 480px;
    overflow-y: auto;
    padding-right: 4px;
}

.scrollable-box-medium {
    max-height: 360px;
    overflow-y: auto;
    padding-right: 4px;
}

.scrollable-box-small {
    max-height: 185px;
    overflow-y: auto;
    padding-right: 4px;
}

/* Barra Ricerca + Ordinamento nelle liste laterali */
.list-filter-bar {
    display: flex;
    gap: 6px;
    margin-bottom: 10px;
}

.list-filter-bar input {
    flex: 1.4;
    padding: 6px 10px;
    font-size: 0.84rem;
}

.list-filter-bar select {
    flex: 1;
    padding: 6px 8px;
    font-size: 0.82rem;
}

/* BORDI COLORATI E BADGE PER GUIDARE GLI STEP */
.step-card-slate { border-top: 4px solid #475569; }
.step-card-blue { border-top: 4px solid #2563eb; }
.step-card-indigo { border-top: 4px solid #6366f1; }
.step-card-emerald { border-top: 4px solid #059669; }

.step-pill {
    font-size: 0.72rem;
    font-weight: 800;
    padding: 3px 8px;
    border-radius: 10px;
    letter-spacing: 0.5px;
    vertical-align: middle;
}

.pill-blue { background: #dbeafe; color: #1e40af; }
.pill-indigo { background: #e0e7ff; color: #3730a3; }
.pill-emerald { background: #d1fae5; color: #065f46; }

/* Barra di progresso visiva per il Monte Ore del Corso */
.hours-progress-bar {
    width: 100%;
    height: 14px;
    background: #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
    margin-top: 4px;
}

.hours-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #2563eb, #059669);
    transition: width 0.25s ease;
}

/* CARD CALIBRAZIONE 3 CAMPI (MASSA | N. PAX | PESO/PAX) DENTRO IL CORSO */
.corso-ricette-calibrazione-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 420px;
    overflow-y: auto;
    padding-right: 4px;
}

.crs-calib-card {
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    border-left: 4px solid #059669;
    border-radius: 6px;
    padding: 10px 12px;
}

.crs-calib-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.crs-calib-orig-badge {
    font-size: 0.75rem;
    background: #e2e8f0;
    color: #334155;
    padding: 2px 8px;
    border-radius: 10px;
}

.crs-calib-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1.2fr auto;
    gap: 8px;
    align-items: end;
}

.crs-calib-field label {
    margin-top: 0;
    font-size: 0.74rem;
    color: #475569;
}

.crs-calib-field input {
    padding: 5px 8px;
    font-size: 0.86rem;
    font-weight: 700;
}

/* BADGE RIASSUNTIVO CLASSIFICAZIONE NELLA BARRA CHIUSA */
.classification-summary-badge {
    font-size: 0.78rem;
    font-weight: 600;
    background: #f1f5f9;
    color: #334155;
    border: 1px solid #cbd5e1;
    padding: 3px 10px;
    border-radius: 12px;
}

/* STATO BOTTONE SALVA QUANDO CI SONO MODIFICHE NON SALVATE */
.btn-unsaved {
    background: #d97706 !important;
    color: #fff !important;
    box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.3);
    animation: pulse-unsaved 2s infinite;
}

@keyframes pulse-unsaved {
    0% { box-shadow: 0 0 0 0 rgba(217, 119, 6, 0.5); }
    70% { box-shadow: 0 0 0 6px rgba(217, 119, 6, 0); }
    100% { box-shadow: 0 0 0 0 rgba(217, 119, 6, 0); }
}

/* BARRA E STILI CHECKLIST INTERATTIVA REPORT CORSO */
.crs-checklist-toolbar {
    width: 100%;
    max-width: 210mm;
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 8px 14px;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.84rem;
    color: #334155;
}

.checklist-item-clickable {
    cursor: pointer;
    user-select: none;
    transition: background-color 0.12s ease;
}

.checklist-item-clickable:hover {
    background-color: #f8fafc;
}

.checklist-check-box {
    width: 15px;
    height: 15px;
    margin-right: 6px;
    accent-color: #059669;
    cursor: pointer;
    flex-shrink: 0;
}

.checklist-checked {
    opacity: 0.55;
    background-color: #f0fdf4 !important;
}

.checklist-checked .dama-ing-name,
.checklist-checked .dama-ing-qty,
.checklist-checked span {
    text-decoration: line-through;
    color: #475569;
}

.crs-attr-item {
    display: flex;
    align-items: center;
    padding: 3px 6px;
    border-radius: 4px;
}

/* BARRA REVISIONE MULTI-RICETTA ESTRATTE DA GEMINI AI */
.ai-multi-bar {
    background: #eff6ff;
    border: 2px solid #3b82f6;
    padding: 12px 16px;
}

.ai-multi-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-size: 0.85rem;
    font-weight: 700;
    color: #1e40af;
}

.ai-multi-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.ai-multi-pill {
    background: #fff;
    border: 1px solid #93c5fd;
    color: #1e3a8a;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}

.ai-multi-pill:hover {
    background: #dbeafe;
}

.ai-multi-pill.active {
    background: #2563eb;
    border-color: #1d4ed8;
    color: #fff;
}

.ai-multi-pill.saved {
    border-color: #10b981;
    background: #ecfdf5;
    color: #065f46;
}

.ai-multi-pill.active.saved {
    background: #059669;
    color: #fff;
}

/* REGOLE DI STAMPA / ESPORTAZIONE PDF A4 */
@page {
    size: A4;
    margin: 8mm;
}

@media print {
    body {
        background: white;
    }
    .no-print {
        display: none !important;
    }
    .workspace {
        display: block;
        padding: 0;
    }
    .preview-panel {
        display: block;
    }
    .dama-sheet {
        box-shadow: none;
        margin: 0;
        padding: 2mm 4mm;
        width: 100%;
        max-width: 100%;
        min-height: 277mm; /* Altezza perfetta di 1 pagina A4 coi margini di stampa */
    }
    /* Stampa corretta quando si stampa il Riepilogo Corso */
    body.printing-corso #vista-editor {
        display: none !important;
    }
    body.printing-corso #vista-format-corsi {
        display: block !important;
        padding: 0 !important;
    }
    body.printing-corso .sub-view-switcher,
    body.printing-corso #sub-vista-format,
    body.printing-corso .corsi-left-panel {
        display: none !important;
    }
    body.printing-corso #sub-vista-corsi,
    body.printing-corso .corsi-workspace-grid,
    body.printing-corso .corsi-right-preview {
        display: block !important;
    }
}