/* Reset e variabili */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --primary: #688E53;
    --primary-dark: #4d6a3b;
    --success: #7fa861;
    --danger: #ef4444;
    --warning: #f59e0b;
    --gray: #6b7280;
    --light: #f0fdf4;
    --dark: #000000;
    --green-light: #e8f3e0;
    --border-radius: 16px;
    --border-radius-sm: 10px;
}

body {
    font-family: 'Roboto Mono', monospace;
    background: var(--light);
    color: var(--dark);
    -webkit-font-smoothing: antialiased;
    font-size: 14px;
}

/* Logo */
.logo-container {
    text-align: center;
    margin-bottom: 20px;
    padding: 0 15px;
}

.logo {
    max-width: min(280px, 70vw);
    height: auto;
    filter: drop-shadow(0 4px 8px rgba(22, 163, 74, 0.2));
}

.logo-container-header {
    flex: 1;
    display: flex;
    justify-content: center;
}

.logo-header {
    max-width: 200px;
    height: auto;
    filter: drop-shadow(0 2px 4px rgba(22, 163, 74, 0.2));
}

/* Schermate */
.screen {
    display: none;
}

.screen.active {
    display: block;
}

/* Container */
.container {
    max-width: 1800px;
    margin: 0 auto;
    padding: 12px;
}

/* Card */
.card {
    background: white;
    border-radius: var(--border-radius);
    padding: 18px;
    box-shadow: 0 2px 12px rgba(22, 163, 74, 0.08);
    margin-bottom: 12px;
    border: 2px solid var(--green-light);
}

.card h2 {
    font-size: 18px;
    margin-bottom: 15px;
    color: var(--primary);
}

/* Header */
header {
    background: white;
    padding: 8px 6px;
    box-shadow: 0 2px 8px rgba(22, 163, 74, 0.08);
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    border-bottom: 3px solid var(--primary);
    position: relative;
    z-index: 100;
}

.logo-container-header {
    flex: 1;
    display: flex;
    justify-content: center;
    padding: 0 4px;
}

.logo-header {
    max-width: 140px;
    height: auto;
}

.user-info {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    font-weight: 500;
    font-size: 9px;
    flex-shrink: 0;
    padding-right: 4px;
}

.role-badge {
    padding: 4px 6px;
    border-radius: 12px;
    font-size: 8px;
    font-weight: 700;
    text-transform: uppercase;
    white-space: nowrap;
    background: var(--light);
}

.role-badge.admin {
    color: var(--primary);
    border: 2px solid var(--primary);
}

.role-badge.operatore {
    color: var(--warning);
    border: 2px solid var(--warning);
}

/* Version badge */
.version-badge {
    position: fixed;
    bottom: 8px;
    right: 8px;
    background: var(--primary);
    color: white;
    padding: 4px 10px;
    border-radius: 16px;
    font-size: 10px;
    font-weight: 600;
    z-index: 999;
    box-shadow: 0 2px 8px rgba(22, 163, 74, 0.3);
}

/* ============================================ */
/* DASHBOARD - NUOVI STILI */
/* ============================================ */

.dashboard-container {
    padding: 20px 15px;
    max-width: 1200px;
    margin: 0 auto;
}

.dashboard-header {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px;
}

.dashboard-header h2 {
    font-size: 28px;
    color: var(--primary);
    margin-bottom: 8px;
}

.dashboard-header p {
    font-size: 14px;
    color: var(--gray);
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    padding: 0 5px;
}

.dashboard-card {
    background: white;
    border-radius: var(--border-radius);
    padding: 25px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 3px solid var(--green-light);
    box-shadow: 0 4px 15px rgba(22, 163, 74, 0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 180px;
}

.dashboard-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(22, 163, 74, 0.2);
    border-color: var(--primary);
}

.dashboard-card:active {
    transform: scale(0.98);
}

.dashboard-card .card-icon {
    font-size: 48px;
    display: block;
    margin-bottom: 15px;
    line-height: 1;
}

.dashboard-card h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 8px;
    line-height: 1.3;
}

.dashboard-card p {
    font-size: 12px;
    color: var(--gray);
    line-height: 1.4;
    margin: 0;
}

/* Nascondi card scanner su desktop */
@media (min-width: 769px) {
    #dashboard-scanner-card {
        display: none;
    }
    
    .dashboard-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ============================================ */
/* SEZIONI E NAVIGAZIONE */
/* ============================================ */

.section-container {
    display: block;
}

.section-container.hidden {
    display: none;
}

.back-to-dashboard {
    background: white;
    padding: 12px 15px;
    display: flex;
    align-items: center;
    gap: 15px;
    border-bottom: 2px solid var(--green-light);
    flex-wrap: wrap;
}

.btn-back {
    background: var(--light);
    color: var(--primary);
    border: 2px solid var(--primary);
    padding: 10px 18px;
    border-radius: var(--border-radius-sm);
    font-size: 14px;
    font-family: 'Roboto Mono', monospace;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.btn-back:hover {
    background: var(--primary);
    color: white;
}

.btn-back:active {
    transform: scale(0.98);
}

.section-title {
    font-size: 18px;
    color: var(--primary);
    margin: 0;
    flex: 1;
}

/* Tabs */
.tabs {
    background: white;
    padding: 8px;
    display: flex;
    gap: 6px;
    overflow-x: auto;
    box-shadow: 0 2px 6px rgba(22, 163, 74, 0.06);
    -webkit-overflow-scrolling: touch;
}

.tabs::-webkit-scrollbar {
    display: none;
}

.tab-btn {
    padding: 10px 14px;
    border: 2px solid transparent;
    background: var(--light);
    cursor: pointer;
    font-size: 12px;
    font-family: 'Roboto Mono', monospace;
    white-space: nowrap;
    border-radius: var(--border-radius-sm);
    transition: all 0.2s ease;
    font-weight: 500;
    flex-shrink: 0;
    min-width: fit-content;
}

.tab-btn:active {
    transform: scale(0.95);
}

.tab-btn.active {
    background: var(--primary);
    color: white;
    font-weight: 700;
    border-color: var(--primary);
}

/* Tab content */
.tab-content {
    display: none;
    padding-top: 12px;
    min-height: 50vh;
}

.tab-content.active {
    display: block;
}

/* Form */
label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    color: var(--dark);
    font-size: 13px;
}

input, textarea, select {
    width: 100%;
    padding: 12px;
    margin-bottom: 12px;
    border: 2px solid var(--green-light);
    border-radius: var(--border-radius-sm);
    font-size: 16px;
    font-family: 'Roboto Mono', monospace;
    transition: border-color 0.2s ease;
    background: white;
    color: var(--dark);
    opacity: 1;
    text-transform: uppercase;
}

/* Eccezioni: email, password e date restano normali */
input[type="email"],
input[type="password"],
input[type="date"] {
    text-transform: none;
}

/* Placeholder in grigio e non uppercase */
input::placeholder,
textarea::placeholder {
    text-transform: none;
    color: var(--gray);
    opacity: 0.7;
}

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.1);
    color: var(--dark);
    opacity: 1;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0;
}

.form-col {
    display: flex;
    flex-direction: column;
}

/* Buttons */
.btn-primary, .btn-secondary, .btn-success, .btn-danger, .btn-edit, .btn-delete {
    padding: 12px 18px;
    border: none;
    border-radius: var(--border-radius-sm);
    font-size: 14px;
    font-family: 'Roboto Mono', monospace;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 600;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    white-space: nowrap;
    text-align: center;
    width: 100%;
    display: block;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:active {
    background: var(--primary-dark);
    transform: scale(0.98);
}

.btn-secondary {
    background: var(--gray);
    color: white;
    font-size: 9px;
    padding: 4px 8px;
    white-space: nowrap;
}

.btn-success {
    background: white;
    color: var(--success);
    border: 2px solid var(--success);
}

.btn-danger {
    background: white;
    color: var(--danger);
    border: 2px solid var(--danger);
}

.btn-edit {
    background: white;
    color: var(--warning);
    border: 2px solid var(--warning);
    padding: 6px 10px;
    font-size: 26px;
    width: auto;
    display: inline-block;
    line-height: 1;
}

.btn-delete {
    background: white;
    color: var(--danger);
    border: 2px solid var(--danger);
    padding: 6px 10px;
    font-size: 26px;
    width: auto;
    display: inline-block;
    line-height: 1;
}

/* Switch checkbox */
.switch-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
    font-size: 13px;
    padding: 8px 0;
}

.switch-label input[type="checkbox"] {
    width: 46px;
    height: 24px;
    margin: 0;
    appearance: none;
    background: var(--gray);
    border-radius: 20px;
    position: relative;
    cursor: pointer;
    transition: background 0.3s;
    flex-shrink: 0;
}

.switch-label input[type="checkbox"]:checked {
    background: var(--primary);
}

.switch-label input[type="checkbox"]::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: white;
    top: 3px;
    left: 3px;
    transition: transform 0.3s;
}

.switch-label input[type="checkbox"]:checked::before {
    transform: translateX(22px);
}

/* Filters bar */
.filters-bar {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}

.filters-bar input,
.filters-bar select {
    width: 100%;
    margin-bottom: 0;
}

.filters-bar button {
    margin-top: 4px;
}

/* Supplier sections */
.supplier-section {
    background: white;
    border-radius: var(--border-radius);
    padding: 12px;
    margin-bottom: 15px;
    border: 2px solid var(--green-light);
    box-shadow: 0 2px 10px rgba(22, 163, 74, 0.08);
}

.supplier-header {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--primary);
}

.supplier-header h3 {
    color: var(--primary);
    font-size: 16px;
    font-weight: 700;
}

.supplier-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    font-size: 12px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    background: var(--light);
    padding: 8px;
    border-radius: 8px;
}

.stat-label {
    color: var(--gray);
    font-size: 10px;
    margin-bottom: 3px;
}

.stat-value {
    font-weight: 700;
    font-size: 15px;
    color: var(--dark);
}

.stat-value.warning {
    color: var(--danger);
}

/* Table */
.table-container {
    overflow-x: auto;
    border-radius: var(--border-radius-sm);
    -webkit-overflow-scrolling: touch;
    margin: 0;
}

table {
    width: 100%;
    background: white;
    overflow: hidden;
    font-size: 12px;
    min-width: 800px;
    table-layout: auto;
}

thead {
    background: var(--primary);
    color: white;
    position: sticky;
    top: 0;
    z-index: 10;
}

th {
    padding: 10px 8px;
    text-align: left;
    white-space: nowrap;
    font-weight: 600;
    font-size: 12px;
}

td {
    padding: 10px 8px;
    text-align: left;
    white-space: nowrap;
    border-bottom: 1px solid var(--light);
    vertical-align: top;
}

/* Colonna Nome: PERMETTI WRAP */
td:first-child,
th:first-child {
    white-space: normal !important;
    word-wrap: break-word;
    word-break: break-word;
    min-width: 120px;
    max-width: 250px;
}

tbody tr {
    transition: background 0.2s;
}

tbody tr:active {
    background: var(--green-light);
}

tbody tr.low-stock {
    background: white;
}

tbody tr.low-stock td {
    border-top: 3px solid var(--danger) !important;
    border-bottom: 3px solid var(--danger) !important;
}

tbody tr.low-stock td:first-child {
    border-left: 3px solid var(--danger) !important;
}

tbody tr.low-stock td:last-child {
    border-right: 3px solid var(--danger) !important;
}

tbody tr.low-stock:active {
    background: var(--green-light);
}

/* Actions column - LAYOUT A DUE A DUE */
td:last-child {
    white-space: normal !important;
    min-width: 140px;
    max-width: 180px;
}

.action-buttons-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    width: 100%;
}

.action-buttons-grid button {
    margin: 0 !important;
    padding: 8px 6px !important;
    font-size: 11px !important;
    width: 100%;
    display: block;
}

/* Report */
.report-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.report-options label {
    margin-top: 10px;
    margin-bottom: 6px;
    color: var(--primary);
    font-weight: 600;
    font-size: 13px;
}

.report-field {
    margin-bottom: 12px;
}

.report-field.hidden {
    display: none;
}

.report-header {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 12px;
}

.report-header h2 {
    font-size: 18px;
}

#report-content,
#report-ricambi-content {
    padding: 15px;
    background: var(--light);
    border-radius: var(--border-radius-sm);
    font-size: 12px;
    line-height: 1.5;
}

#report-content h3,
#report-ricambi-content h3 {
    color: var(--primary);
    margin-bottom: 10px;
    font-size: 16px;
}

#report-content h4,
#report-ricambi-content h4 {
    color: var(--primary-dark);
    margin-top: 12px;
    margin-bottom: 8px;
    font-size: 14px;
}

#report-content p,
#report-ricambi-content p {
    margin-bottom: 6px;
    word-wrap: break-word;
}

#report-content hr,
#report-ricambi-content hr {
    border: none;
    border-top: 2px solid var(--green-light);
    margin: 12px 0;
}

#report-content table,
#report-ricambi-content table {
    margin-top: 10px;
    font-size: 10px;
    overflow-x: auto;
    display: block;
}

/* Print styles */
@media print {
    body * {
        visibility: hidden;
    }
    
    #report-result, #report-result *,
    #report-ricambi-result, #report-ricambi-result * {
        visibility: visible;
    }
    
    #report-result,
    #report-ricambi-result {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
    }
    
    .report-header button {
        display: none;
    }
}

/* Scanner */
#scanner-container {
    max-width: 100%;
    margin: 0 auto;
}

#reader {
    border: 3px solid var(--primary);
    border-radius: var(--border-radius);
    overflow: hidden;
    width: 100%;
}

#reader video {
    width: 100%;
    height: auto;
    display: block;
}

.action-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin: 15px 0;
}

#scanner-result {
    margin-top: 15px;
    padding: 15px;
    background: var(--light);
    border-radius: var(--border-radius);
    border: 2px solid var(--primary);
}

#scanner-result h3 {
    color: var(--primary);
    font-size: 16px;
    margin-bottom: 8px;
}

#scanner-result p {
    font-size: 13px;
    margin-bottom: 12px;
    word-wrap: break-word;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    min-height: 100vh;
    height: 100dvh;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    padding: 15px;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: white;
    padding: 20px;
    border-radius: var(--border-radius);
    max-width: 500px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    border: 3px solid var(--primary);
    box-shadow: 0 8px 32px rgba(22, 163, 74, 0.3);
}

.modal-content h3 {
    color: var(--primary);
    margin-bottom: 12px;
    font-size: 18px;
}

/* Modal header con pulsante chiusura */
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.modal-header h3 {
    margin-bottom: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 32px;
    color: var(--gray);
    cursor: pointer;
    padding: 0;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
    line-height: 1;
}

.modal-close:hover {
    background: var(--light);
    color: var(--danger);
    transform: rotate(90deg);
}

.modal-close:active {
    transform: scale(0.9) rotate(90deg);
}

.modal-content p {
    margin-bottom: 10px;
    font-size: 14px;
}

.modal-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 15px;
}

/* Link text */
.link-text {
    text-align: center;
    margin-top: 12px;
    font-size: 13px;
}

.link-text a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

.link-text a:active {
    color: var(--primary-dark);
}

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

/* Fix opacita elementi */
button, input, textarea, select, label, span, div, td, th, p, h1, h2, h3, h4 {
    opacity: 1 !important;
}

/* Scrollbar personalizzata */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--light);
}

::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 10px;
}

/* ============================================ */
/* MOBILE OPTIMIZATION - SOLO COLONNE ESSENZIALI */
/* ============================================ */

@media (max-width: 768px) {
    /* Dashboard mobile */
    .dashboard-container {
        padding: 15px 10px;
    }
    
    .dashboard-header {
        padding: 15px 10px;
        margin-bottom: 20px;
    }
    
    .dashboard-header h2 {
        font-size: 22px;
    }
    
    .dashboard-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    
    .dashboard-card {
        padding: 20px 15px;
        min-height: 150px;
    }
    
    .dashboard-card .card-icon {
        font-size: 36px;
        margin-bottom: 10px;
    }
    
    .dashboard-card h3 {
        font-size: 13px;
    }
    
    .dashboard-card p {
        font-size: 11px;
        display: none; /* Nascondi descrizione su mobile per spazio */
    }
    
    /* Back to dashboard mobile */
    .back-to-dashboard {
        padding: 10px;
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .btn-back {
        padding: 8px 14px;
        font-size: 12px;
    }
    
    .section-title {
        font-size: 16px;
    }
    
    /* Elimina min-width per far stare tutto nello schermo */
    table {
        min-width: auto;
        width: 100%;
    }
    
    /* NASCONDI colonne non essenziali su mobile SOLO PER INVENTARIO:
       - Soglia (4)
       - Pr. Acq. NETTO (5)
       - IVA % (6)
       - Barcode (8)
       - Note (9)
    */
    
    /* Soglia */
    #tab-inventario th:nth-child(4),
    #tab-inventario td:nth-child(4) {
        display: none;
    }
    
    /* Pr. Acq. NETTO */
    #tab-inventario th:nth-child(5),
    #tab-inventario td:nth-child(5) {
        display: none;
    }
    
    /* IVA % */
    #tab-inventario th:nth-child(6),
    #tab-inventario td:nth-child(6) {
        display: none;
    }
    
    /* Barcode */
    #tab-inventario th:nth-child(8),
    #tab-inventario td:nth-child(8) {
        display: none;
    }
    
    /* Note */
    #tab-inventario th:nth-child(9),
    #tab-inventario td:nth-child(9) {
        display: none;
    }
    
    /* OTTIMIZZA colonne visibili su mobile - COMPATTE - SOLO INVENTARIO */
    
    /* Nome - piu stretto, va a capo */
    #tab-inventario td:nth-child(1),
    #tab-inventario th:nth-child(1) {
        min-width: 80px;
        max-width: 120px;
        white-space: normal !important;
        word-wrap: break-word !important;
        word-break: break-word !important;
        font-size: 11px;
        padding: 8px 4px !important;
    }
    
    /* Codice - compatto */
    #tab-inventario td:nth-child(2),
    #tab-inventario th:nth-child(2) {
        min-width: 45px;
        max-width: 60px;
        font-size: 10px;
        padding: 8px 4px !important;
    }
    
    /* Quantita - compatto centrato */
    #tab-inventario td:nth-child(3),
    #tab-inventario th:nth-child(3) {
        min-width: 35px;
        max-width: 45px;
        text-align: center !important;
        font-size: 11px;
        padding: 8px 4px !important;
    }
    
    /* Prezzo Vendita - compatto */
    #tab-inventario td:nth-child(7),
    #tab-inventario th:nth-child(7) {
        min-width: 50px;
        max-width: 65px;
        font-size: 10px;
        padding: 8px 4px !important;
    }
    
    /* Azioni - compatto */
    #tab-inventario td:nth-child(10),
    #tab-inventario th:nth-child(10) {
        min-width: 80px;
        max-width: 90px;
        padding: 8px 4px !important;
    }
    
    /* Riduci padding generale celle */
    td, th {
        padding: 8px 4px !important;
        font-size: 11px;
    }
    
    /* Pulsanti azioni piu piccoli */
    .action-buttons-grid button {
        padding: 6px 4px !important;
        font-size: 14px !important;
    }
    
    /* Font header piu piccolo */
    th {
        font-size: 10px;
        font-weight: 700;
    }
    
    /* Fix badge Operatore che esce dallo schermo */
    .role-badge {
        font-size: 9px !important;
        padding: 4px 6px !important;
    }
    
    /* ===== CLASSI GENERICHE HIDE/SHOW ===== */
    .hide-on-mobile {
        display: none !important;
    }
    
    .show-on-mobile {
        display: inline !important;
    }
    
    /* ===== OTTIMIZZAZIONE TABELLA MOVIMENTI ===== */
    /* 5 colonne visibili su mobile: Data, Utente, Articolo, Tipo, Quantita */
    
    #tab-movimenti table,
    #tab-ricambi-movimenti table {
        font-size: 12px;
        width: 100%;
        table-layout: fixed;
    }
    
    /* NASCONDI Codice e Note su mobile */
    #tab-movimenti th:nth-child(6),
    #tab-movimenti td:nth-child(6),
    #tab-movimenti th:nth-child(7),
    #tab-movimenti td:nth-child(7),
    #tab-ricambi-movimenti th:nth-child(6),
    #tab-ricambi-movimenti td:nth-child(6),
    #tab-ricambi-movimenti th:nth-child(7),
    #tab-ricambi-movimenti td:nth-child(7) {
        display: none !important;
    }
    
    /* Data - 20% - leggibile con anno a 2 cifre */
    #tab-movimenti th:nth-child(1),
    #tab-movimenti td:nth-child(1),
    #tab-ricambi-movimenti th:nth-child(1),
    #tab-ricambi-movimenti td:nth-child(1) {
        display: table-cell !important;
        width: 20%;
        font-size: 11px;
        padding: 10px 5px !important;
        white-space: nowrap;
    }
    
    /* Utente (iniziali) - 15% */
    #tab-movimenti th:nth-child(2),
    #tab-movimenti td:nth-child(2),
    #tab-ricambi-movimenti th:nth-child(2),
    #tab-ricambi-movimenti td:nth-child(2) {
        display: table-cell !important;
        width: 15%;
        text-align: center !important;
        font-size: 12px;
        padding: 10px 4px !important;
        font-weight: 700;
    }
    
    /* Articolo - 35% */
    #tab-movimenti th:nth-child(3),
    #tab-movimenti td:nth-child(3),
    #tab-ricambi-movimenti th:nth-child(3),
    #tab-ricambi-movimenti td:nth-child(3) {
        display: table-cell !important;
        width: 35%;
        font-size: 11px;
        padding: 10px 5px !important;
        white-space: normal !important;
        word-wrap: break-word !important;
        word-break: break-word !important;
        line-height: 1.3;
    }
    
    /* Tipo (emoji +/-) - 13% */
    #tab-movimenti th:nth-child(4),
    #tab-movimenti td:nth-child(4),
    #tab-ricambi-movimenti th:nth-child(4),
    #tab-ricambi-movimenti td:nth-child(4) {
        display: table-cell !important;
        width: 13%;
        text-align: center !important;
        padding: 10px 4px !important;
        font-size: 18px;
    }
    
    /* Quantita - 17% */
    #tab-movimenti th:nth-child(5),
    #tab-movimenti td:nth-child(5),
    #tab-ricambi-movimenti th:nth-child(5),
    #tab-ricambi-movimenti td:nth-child(5) {
        display: table-cell !important;
        width: 17%;
        text-align: center !important;
        font-size: 13px;
        padding: 10px 4px !important;
        font-weight: 700;
    }
    
    /* Header tabella movimenti */
    #tab-movimenti th,
    #tab-ricambi-movimenti th {
        font-size: 10px;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.3px;
    }
}

/* ============================================ */
/* DESKTOP/TABLET OPTIMIZATION */
/* ============================================ */

@media (min-width: 769px) {
    /* Dashboard desktop */
    .dashboard-container {
        padding: 40px 30px;
    }
    
    .dashboard-header {
        margin-bottom: 40px;
    }
    
    .dashboard-header h2 {
        font-size: 32px;
    }
    
    .dashboard-header p {
        font-size: 16px;
    }
    
    .dashboard-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 25px;
        max-width: 900px;
        margin: 0 auto;
    }
    
    .dashboard-card {
        padding: 35px 25px;
        min-height: 220px;
    }
    
    .dashboard-card .card-icon {
        font-size: 56px;
        margin-bottom: 20px;
    }
    
    .dashboard-card h3 {
        font-size: 18px;
        margin-bottom: 10px;
    }
    
    .dashboard-card p {
        font-size: 14px;
    }
    
    /* Back to dashboard desktop */
    .back-to-dashboard {
        padding: 15px 20px;
    }
    
    .btn-back {
        padding: 12px 24px;
        font-size: 14px;
    }
    
    .btn-back:hover {
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(22, 163, 74, 0.3);
    }
    
    .section-title {
        font-size: 22px;
    }
    
    /* Classi generiche per desktop */
    .show-on-mobile {
        display: none !important;
    }
    
    .hide-on-mobile {
        display: table-cell !important;
    }
    
    body {
        font-size: 16px;
    }
    
    .container {
        padding: 20px;
    }
    
    .card {
        padding: 30px;
    }
    
    .card h2 {
        font-size: 24px;
    }
    
    header {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        padding: 20px;
    }
    
    .logo-container-header {
        flex: 1;
        display: flex;
        justify-content: center;
        padding: 0;
    }
    
    .logo-header {
        max-width: 220px;
    }
    
    .user-info {
        font-size: 13px;
        flex-shrink: 0;
        gap: 8px;
        padding-right: 0;
    }
    
    .role-badge {
        font-size: 12px;
        padding: 8px 16px;
        border-radius: 16px;
    }
    
    .btn-secondary {
        font-size: 11px;
        padding: 6px 10px;
    }
    
    .version-badge {
        font-size: 11px;
        padding: 6px 12px;
    }
    
    .tabs {
        padding: 15px 20px;
        gap: 10px;
        position: static;
    }
    
    .tab-btn {
        font-size: 16px;
        padding: 14px 24px;
    }
    
    .tab-btn:hover {
        background: var(--green-light);
        border-color: var(--primary);
    }
    
    .form-row {
        grid-template-columns: 1fr 1fr;
        gap: 20px;
    }
    
    label {
        font-size: 14px;
    }
    
    .btn-primary, .btn-secondary, .btn-success, .btn-danger {
        width: auto;
        display: inline-block;
        font-size: 16px;
        padding: 14px 28px;
    }
    
    .btn-primary:hover {
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(22, 163, 74, 0.3);
    }
    
    .btn-edit, .btn-delete {
        font-size: 28px;
        padding: 8px 12px;
        line-height: 1;
    }
    
    .filters-bar {
        flex-direction: row;
        align-items: center;
        gap: 15px;
    }
    
    .filters-bar input,
    .filters-bar select {
        flex: 1;
        min-width: 200px;
    }
    
    .filters-bar button {
        margin-top: 0;
        width: auto;
    }
    
    .switch-label {
        font-size: 14px;
    }
    
    .switch-label input[type="checkbox"] {
        width: 42px;
        height: 22px;
    }
    
    .switch-label input[type="checkbox"]::before {
        width: 16px;
        height: 16px;
        top: 3px;
        left: 3px;
    }
    
    .switch-label input[type="checkbox"]:checked::before {
        transform: translateX(20px);
    }
    
    .supplier-header {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }
    
    .supplier-header h3 {
        font-size: 22px;
    }
    
    .supplier-stats {
        display: flex;
        gap: 20px;
    }
    
    .stat-item {
        align-items: flex-end;
        text-align: right;
        background: transparent;
        padding: 0;
    }
    
    .stat-label {
        font-size: 12px;
    }
    
    .stat-value {
        font-size: 18px;
    }
    
    .table-container {
        margin: 0;
    }
    
    table {
        font-size: 14px;
        min-width: auto;
    }
    
    th {
        font-size: 14px;
        padding: 16px 12px;
    }
    
    td {
        padding: 16px 12px;
    }
    
    td:first-child,
    th:first-child {
        max-width: 300px;
        min-width: 150px;
    }
    
    td:last-child {
        min-width: 160px;
        max-width: 200px;
    }
    
    .action-buttons-grid {
        gap: 6px;
    }
    
    .action-buttons-grid button {
        padding: 10px 8px !important;
        font-size: 13px !important;
    }
    
    .btn-success:hover {
        background: var(--success);
        color: white;
        transform: translateY(-1px);
    }
    
    .btn-danger:hover {
        background: var(--danger);
        color: white;
        transform: translateY(-1px);
    }
    
    .btn-edit:hover {
        background: var(--warning);
        color: white;
        transform: translateY(-1px);
    }
    
    .btn-delete:hover {
        background: var(--danger);
        color: white;
        transform: translateY(-1px);
    }
    
    tbody tr:hover {
        background: var(--green-light);
    }
    
    .report-header {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }
    
    .report-header h2 {
        font-size: 24px;
    }
    
    #report-content,
    #report-ricambi-content {
        font-size: 14px;
        padding: 25px;
    }
    
    #report-content h3,
    #report-ricambi-content h3 {
        font-size: 24px;
    }
    
    #report-content h4,
    #report-ricambi-content h4 {
        font-size: 18px;
    }
    
    #report-content table,
    #report-ricambi-content table {
        font-size: 13px;
    }
    
    #scanner-container {
        max-width: 500px;
    }
    
    .action-buttons {
        gap: 15px;
        margin: 25px 0;
    }
    
    .modal-content {
        padding: 35px;
    }
    
    .modal-content h3 {
        font-size: 24px;
    }
    
    .modal-buttons {
        gap: 15px;
        margin-top: 25px;
    }
}

/* Large desktop */
@media (min-width: 1400px) {
    .dashboard-grid {
        max-width: 1100px;
        gap: 30px;
    }
    
    .dashboard-card {
        padding: 40px 30px;
        min-height: 250px;
    }
    
    .dashboard-card .card-icon {
        font-size: 64px;
    }
    
    .dashboard-card h3 {
        font-size: 20px;
    }
    
    .supplier-section {
        padding: 25px;
    }
    
    table {
        font-size: 15px;
    }
    
    th {
        font-size: 15px;
        padding: 18px 14px;
    }
    
    td {
        padding: 18px 14px;
    }
    
    td:first-child,
    th:first-child {
        max-width: 400px;
        min-width: 180px;
    }
    
    td:last-child {
        min-width: 180px;
        max-width: 220px;
    }
    
    .action-buttons-grid button {
        padding: 11px 10px !important;
        font-size: 14px !important;
    }
}

/* Safe area for iPhone notch */
@supports (padding: max(0px)) {
    body {
        padding-left: max(12px, env(safe-area-inset-left));
        padding-right: max(12px, env(safe-area-inset-right));
        padding-bottom: max(12px, env(safe-area-inset-bottom));
    }
    
    header {
        padding-top: max(12px, env(safe-area-inset-top));
    }
}

/* ============================================ */
/* MOBILE WARNING E PWA INSTALL */
/* ============================================ */

/* Avviso dispositivo mobile */
.mobile-warning {
    background: linear-gradient(135deg, #FEF3C7 0%, #FDE68A 100%);
    border: 2px solid #F59E0B;
    border-radius: var(--border-radius);
    padding: 15px;
    margin: 15px 0;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.warning-content {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.warning-icon {
    font-size: 28px;
    flex-shrink: 0;
}

.warning-text {
    flex: 1;
    font-size: 13px;
    line-height: 1.6;
    color: var(--dark);
}

.warning-text strong {
    color: #92400E;
}

/* Container pulsante installa */
.install-container {
    margin: 15px 0;
}

.btn-install {
    width: 100%;
    padding: 14px 20px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    border: none;
    border-radius: var(--border-radius-sm);
    font-size: 15px;
    font-family: 'Roboto Mono', monospace;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(22, 163, 74, 0.3);
    transition: all 0.3s ease;
    animation: pulse 2s infinite;
}

.btn-install:active {
    transform: scale(0.98);
    box-shadow: 0 2px 8px rgba(22, 163, 74, 0.3);
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 4px 12px rgba(22, 163, 74, 0.3);
    }
    50% {
        box-shadow: 0 4px 20px rgba(22, 163, 74, 0.5);
    }
}

/* Istruzioni installazione nel modale */
.install-instructions {
    margin: 15px 0;
    padding: 15px;
    background: var(--light);
    border-radius: var(--border-radius-sm);
    border-left: 4px solid var(--primary);
}

.install-instructions h4 {
    color: var(--primary);
    margin-bottom: 12px;
    font-size: 16px;
}

.install-instructions ol {
    font-size: 14px;
}

.install-instructions li {
    margin-bottom: 10px;
}

/* Desktop hover per pulsante installa */
@media (min-width: 769px) {
    .btn-install:hover {
        transform: translateY(-2px);
        box-shadow: 0 6px 16px rgba(22, 163, 74, 0.4);
    }
    
    .warning-text {
        font-size: 14px;
    }
    
    .warning-icon {
        font-size: 32px;
    }
}

/* ============================================ */
/* SEARCH BAR */
/* ============================================ */

.search-bar {
    margin-bottom: 10px;
}

.search-bar input {
    width: 100%;
    padding: 14px 18px;
    font-size: 16px;
    border: 2px solid var(--primary);
    border-radius: 12px;
    background: white;
    color: var(--dark);
    font-family: 'Roboto Mono', monospace;
    font-weight: 500;
    transition: all 0.2s ease;
}

.search-bar input:focus {
    outline: none;
    border-color: var(--primary-dark);
    box-shadow: 0 0 0 4px rgba(22, 163, 74, 0.15);
}

/* ============================================ */
/* TOGGLE RESTYLING */
/* ============================================ */

.toggle-container {
    display: flex;
    align-items: center;
    background: white;
    border: 2px solid var(--primary);
    border-radius: 12px;
    padding: 10px 15px;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

.toggle-container:hover {
    border-color: var(--primary-dark);
    background: var(--light);
}

.toggle-checkbox {
    display: none;
}

.toggle-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    cursor: pointer;
    margin: 0;
}

.toggle-text {
    font-size: 13px;
    font-weight: 600;
    color: var(--dark);
    margin-right: 12px;
}

.toggle-switch {
    position: relative;
    width: 48px;
    height: 26px;
    background: var(--gray);
    border-radius: 20px;
    transition: background 0.3s ease;
    flex-shrink: 0;
}

.toggle-switch::before {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: white;
    top: 3px;
    left: 3px;
    transition: transform 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.toggle-checkbox:checked + .toggle-label .toggle-switch {
    background: var(--primary);
}

.toggle-checkbox:checked + .toggle-label .toggle-switch::before {
    transform: translateX(22px);
}

/* ============================================ */
/* AGGIORNAMENTO RESPONSIVE */
/* ============================================ */

@media (min-width: 769px) {
    .search-bar input {
        font-size: 18px;
        padding: 16px 20px;
    }
    
    .filters-bar {
        flex-direction: row;
        align-items: center;
        gap: 12px;
    }
    
    .filters-bar select {
        flex: 1;
        min-width: 180px;
    }
    
    .toggle-container {
        flex-shrink: 0;
        min-width: fit-content;
    }
    
    .toggle-text {
        font-size: 14px;
    }
}

/* ============================================ */
/* POP-UP NOVITA VERSIONE */
/* ============================================ */

#whats-new-modal {
    z-index: 99999 !important;
}

.whats-new-content {
    max-width: 550px;
    animation: slideInUp 0.4s ease-out;
    position: relative;
    z-index: 100000 !important;
}

.whats-new-header {
    text-align: center;
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 2px solid #e5e7eb;
}

.whats-new-header h3 {
    font-size: 26px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 8px;
}

.version-date {
    font-size: 14px;
    color: var(--gray);
    font-weight: 500;
}

.whats-new-body {
    margin: 25px 0;
}

.new-feature {
    display: flex;
    align-items: flex-start;
    gap: 15px;
    padding: 15px;
    margin-bottom: 15px;
    background: linear-gradient(135deg, #f0fdf4 0%, #ecfdf5 100%);
    border-radius: 12px;
    border-left: 4px solid var(--primary);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.new-feature:hover {
    transform: translateX(5px);
    box-shadow: 0 4px 12px rgba(22, 163, 74, 0.15);
}

.feature-icon {
    font-size: 32px;
    flex-shrink: 0;
    line-height: 1;
}

.feature-content h4 {
    font-size: 16px;
    font-weight: 600;
    color: var(--dark);
    margin: 0 0 5px 0;
}

.feature-content p {
    font-size: 14px;
    color: var(--gray);
    margin: 0;
    line-height: 1.5;
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive per mobile */
@media (max-width: 768px) {
    .whats-new-content {
        max-width: 95%;
        margin: 10px;
    }
    
    .whats-new-header h3 {
        font-size: 22px;
    }
    
    .new-feature {
        padding: 12px;
        gap: 12px;
    }
    
    .feature-icon {
        font-size: 28px;
    }
    
    .feature-content h4 {
        font-size: 15px;
    }
    
    .feature-content p {
        font-size: 13px;
    }
}