* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    color: #2c3e50;
    padding: 1.5rem;
    text-align: center;
    border-radius: 15px;
    margin-bottom: 25px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

header h1 {
    font-size: 2.2rem;
    font-weight: 700;
    background: linear-gradient(135deg, #2c3e50, #3498db);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
}

/* Stile per il lucchetto nel titolo */
.header-lock {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3498db, #2980b9);
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.3);
    flex-shrink: 0;
}

.header-lock:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(52, 152, 219, 0.4);
}

.header-lock.unlocked {
    background: linear-gradient(135deg, #27ae60, #229954);
    box-shadow: 0 4px 15px rgba(39, 174, 96, 0.3);
}

.header-lock.unlocked:hover {
    background: linear-gradient(135deg, #229954, #1e8449);
    box-shadow: 0 6px 20px rgba(39, 174, 96, 0.4);
}

.header-lock svg {
    width: 20px;
    height: 20px;
    fill: white;
}

main {
    max-width: 1200px;
    margin: 0 auto;
}

section {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 2rem;
    margin-bottom: 1.5rem;
    border-radius: 15px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

section:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
}

h2 {
    margin-bottom: 1.5rem;
    color: #2c3e50;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.4rem;
    font-weight: 600;
    border-bottom: 2px solid #3498db;
    padding-bottom: 0.5rem;
}

/* Stili per il tooltip */
.tooltip-container {
    position: relative;
    display: inline-block;
}

.tooltip-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
    border-radius: 50%;
    font-size: 14px;
    font-weight: bold;
    cursor: help;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(52, 152, 219, 0.3);
}

.tooltip-icon:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.4);
}

.tooltip-text {
    visibility: hidden;
    width: 250px;
    background: rgba(51, 51, 51, 0.95);
    backdrop-filter: blur(10px);
    color: white;
    text-align: center;
    border-radius: 10px;
    padding: 12px;
    position: absolute;
    z-index: 1000;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    opacity: 0;
    transition: all 0.3s ease;
    font-size: 0.9rem;
    line-height: 1.4;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.tooltip-text::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border-width: 6px;
    border-style: solid;
    border-color: rgba(51, 51, 51, 0.95) transparent transparent transparent;
}

.tooltip-container:hover .tooltip-text {
    visibility: visible;
    opacity: 1;
    transform: translateX(-50%) translateY(-5px);
}

.search-container {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

input[type="text"],
input[type="password"],
input[type="date"],
select,
textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 1rem;
    transition: all 0.3s ease;
    background: rgba(255, 255, 255, 0.9);
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="date"]:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
    background: white;
}

button {
    padding: 0.75rem 1.5rem;
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.3);
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(52, 152, 219, 0.4);
    background: linear-gradient(135deg, #2980b9, #2573a7);
}

button:active {
    transform: translateY(0);
}

#admin-btn {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    box-shadow: 0 4px 15px rgba(231, 76, 60, 0.3);
}

#admin-btn:hover {
    background: linear-gradient(135deg, #c0392b, #a93226);
    box-shadow: 0 6px 20px rgba(231, 76, 60, 0.4);
}

/* Stile per le card dei risultati mobile */
.commesse-cards {
    display: none;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1rem;
}

.commessa-card {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 15px;
    padding: 1.5rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.commessa-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
    border-color: rgba(52, 152, 219, 0.3);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid rgba(52, 152, 219, 0.2);
}

.cod-commessa {
    font-size: 1.3rem;
    font-weight: 700;
    color: #2c3e50;
    margin: 0;
}

.stato-badge {
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: bold;
    text-transform: uppercase;
    white-space: nowrap;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    text-align: center;
    display: inline-block;
    min-width: 120px;
}

.stato-attiva { background: linear-gradient(135deg, #d4edda, #c3e6cb); color: #155724; }
.stato-non-attiva { background: linear-gradient(135deg, #f8d7da, #f5c6cb); color: #721c24; }
.stato-attesa { background: linear-gradient(135deg, #fff3cd, #ffeaa7); color: #856404; }
.stato-lavorazione { background: linear-gradient(135deg, #cce7ff, #b3d9ff); color: #004085; }
.stato-pronta { background: linear-gradient(135deg, #d1ecf1, #bee5eb); color: #0c5460; }
.stato-conclusa { background: linear-gradient(135deg, #e2e3e5, #d6d8db); color: #383d41; }
.stato-default { background: linear-gradient(135deg, #f8f9fa, #e9ecef); color: #6c757d; }

.card-content {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.card-row {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.card-row .label {
    font-weight: 600;
    color: #2c3e50;
    font-size: 0.9rem;
}

.card-row .value {
    color: #333;
    line-height: 1.5;
}

.no-results {
    text-align: center;
    padding: 3rem;
    color: #666;
    font-style: italic;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 15px;
    border: 2px dashed #ddd;
    font-size: 1.1rem;
}

.risultati-header {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    border-radius: 10px;
    text-align: center;
    border: 1px solid rgba(52, 152, 219, 0.2);
}

/* Tabella desktop RISULTATI */
#tabella-risultati table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
    display: table;
    background: white;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

#tabella-risultati th,
#tabella-risultati td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid #e0e0e0;
}

#tabella-risultati th {
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
    font-weight: 600;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

#tabella-risultati tr:hover {
    background-color: rgba(52, 152, 219, 0.05);
}

/* ORDINE COLONNE PER TABELLA RISULTATI */
#tabella-risultati th:nth-child(1), /* Cod. Commessa */
#tabella-risultati td:nth-child(1) {
    width: 120px;
}

#tabella-risultati th:nth-child(2), /* Descrizione */
#tabella-risultati td:nth-child(2) {
    width: auto;
}

#tabella-risultati th:nth-child(3), /* Stato */
#tabella-risultati td:nth-child(3) {
    width: 180px;
    min-width: 180px;
}

#tabella-risultati th:nth-child(4), /* Prev. Consegna */
#tabella-risultati td:nth-child(4) {
    width: 120px;
}

#tabella-risultati th:nth-child(5), /* Note */
#tabella-risultati td:nth-child(5) {
    width: 200px;
}

/* Tabella amministratore */
.admin-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1.5rem;
    table-layout: fixed;
    background: white;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 4px 25px rgba(0, 0, 0, 0.1);
}

.admin-table th,
.admin-table td {
    padding: 0.8rem;
    text-align: left;
    border-bottom: 1px solid #e0e0e0;
    word-wrap: break-word;
    vertical-align: middle;
    white-space: normal;
    overflow: hidden;
    text-overflow: ellipsis;
}

.admin-table th {
    background: linear-gradient(135deg, #2c3e50, #34495e);
    color: white;
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.admin-table tr:hover {
    background-color: rgba(52, 152, 219, 0.08);
}

.admin-table tr:last-child td {
    border-bottom: none;
}

/* DIMENSIONI COLONNE AMMINISTRATORE */
.admin-table th:nth-child(1), /* Cod. Cliente */
.admin-table td:nth-child(1) {
    width: 100px;
    min-width: 100px;
    max-width: 100px;
}

.admin-table th:nth-child(2), /* Cod. Commessa */
.admin-table td:nth-child(2) {
    width: 120px;
    min-width: 120px;
    max-width: 120px;
}

.admin-table th:nth-child(3), /* Descrizione */
.admin-table td:nth-child(3) {
    width: 280px;
    min-width: 280px;
    max-width: 280px;
}

.admin-table th:nth-child(4), /* Stato */
.admin-table td:nth-child(4) {
    width: 160px;
    min-width: 160px;
    max-width: 160px;
}

.admin-table th:nth-child(5), /* Prev. Consegna */
.admin-table td:nth-child(5) {
    width: 120px;
    min-width: 120px;
    max-width: 120px;
}

.admin-table th:nth-child(6), /* Note */
.admin-table td:nth-child(6) {
    width: 180px;
    min-width: 180px;
    max-width: 180px;
}

.admin-table th:nth-child(7), /* Azioni */
.admin-table td:nth-child(7) {
    width: 150px;
    min-width: 150px;
    max-width: 150px;
}

/* Pulsanti azioni tabella compatti */
.btn-actions {
    display: flex;
    gap: 0.4rem;
    justify-content: center;
}

.btn-modifica, .btn-elimina {
    padding: 0.5rem 0.8rem;
    font-size: 0.75rem;
    min-width: 70px;
    text-align: center;
    white-space: nowrap;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.btn-modifica {
    background: linear-gradient(135deg, #f39c12, #e67e22);
    color: white;
}

.btn-modifica:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(243, 156, 18, 0.3);
    background: linear-gradient(135deg, #e67e22, #d35400);
}

.btn-elimina {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    color: white;
}

.btn-elimina:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(231, 76, 60, 0.3);
    background: linear-gradient(135deg, #c0392b, #a93226);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
    margin: 2% auto;
    padding: 1.5rem;
    border-radius: 15px;
    width: 96%;
    max-width: 1400px;
    position: relative;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.3);
    animation: slideIn 0.3s ease;
    max-height: 90vh;
    overflow-y: auto;
}

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

/* FINESTRA GESTIONE COMMESSE */
.admin-content {
    max-width: 1400px !important;
    width: 96% !important;
    margin: 2% auto !important;
    padding: 1.5rem;
    max-height: 90vh;
    overflow-y: auto;
}

.admin-content h2 {
    font-size: 1.6rem;
    margin-bottom: 1.2rem;
    color: #2c3e50;
    text-align: center;
    border-bottom: 3px solid #3498db;
    padding-bottom: 0.8rem;
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    position: absolute;
    right: 1.2rem;
    top: 1.2rem;
    transition: all 0.3s ease;
    width: 35px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    z-index: 10001;
}

.close:hover {
    color: #e74c3c;
    background: rgba(231, 76, 60, 0.1);
    transform: rotate(90deg);
}

/* Form */
.form-group {
    margin-bottom: 1.2rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: #2c3e50;
    font-size: 0.9rem;
}

/* CORREZIONE: Aggiunge spazio specifico nel form di login */
#login-form input[type="password"] {
    margin-bottom: 1rem !important;
}

.form-buttons {
    display: flex;
    gap: 0.8rem;
    margin-top: 1.5rem;
}

.form-buttons button {
    flex: 1;
    padding: 0.8rem;
    font-size: 0.9rem;
}

/* MESSAGGIO LOGIN - SFONDO ROSA RIMOSSO */
#login-message {
    margin-top: 0.5rem;
    color: #e74c3c;
    font-weight: 600;
    text-align: center;
    padding: 0.6rem;
    border-radius: 6px;
    background: transparent; /* SFONDO TRASPARENTE */
    font-size: 0.9rem;
    border: none; /* NESSUN BORDO */
}

/* PULSANTI AMMINISTRAZIONE - PERFETTAMENTE ALLINEATI E STESSA DIMENSIONE */
.admin-actions {
    margin-bottom: 1.5rem;
    display: flex;
    gap: 0.8rem;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    width: 100%;
}

.admin-actions button {
    flex: 1;
    min-width: 180px;
    max-width: 200px;
    padding: 0.9rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 10px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    border: none;
    cursor: pointer;
    text-align: center;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
}

/* Pulsante Nuova Commessa */
#nuova-commessa-btn {
    background: linear-gradient(135deg, #27ae60, #229954);
    color: white;
}

#nuova-commessa-btn:hover {
    background: linear-gradient(135deg, #229954, #1e8449);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(39, 174, 96, 0.3);
}

/* Pulsante Logout */
#logout-btn {
    background: linear-gradient(135deg, #95a5a6, #7f8c8d);
    color: white;
}

#logout-btn:hover {
    background: linear-gradient(135deg, #7f8c8d, #6c7b7d);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(149, 165, 166, 0.3);
}

/* Messaggi di stato */
.message {
    padding: 12px 16px;
    margin: 8px 0;
    border-radius: 10px;
    font-weight: 600;
    border: 1px solid transparent;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    font-size: 0.9rem;
}

.message.success {
    background: linear-gradient(135deg, #d4edda, #c3e6cb);
    color: #155724;
    border-color: #b1dfbb;
}

.message.error {
    background: linear-gradient(135deg, #f8d7da, #f5c6cb);
    color: #721c24;
    border-color: #f1b0b7;
}

.message.warning {
    background: linear-gradient(135deg, #fff3cd, #ffeaa7);
    color: #856404;
    border-color: #ffda6a;
}

.message.info {
    background: linear-gradient(135deg, #d1ecf1, #bee5eb);
    color: #0c5460;
    border-color: #abdde5;
}

/* Paginazione */
.paginazione {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 20px 0;
    gap: 12px;
    flex-wrap: wrap;
    padding: 15px;
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    border-radius: 12px;
    border: 1px solid rgba(52, 152, 219, 0.2);
}

.paginazione-controls {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.paginazione button {
    padding: 8px 12px;
    border: 2px solid #3498db;
    background: white;
    color: #3498db;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.3s ease;
    font-size: 0.85rem;
    font-weight: 600;
    box-shadow: 0 2px 6px rgba(52, 152, 219, 0.2);
}

.paginazione button:hover:not(:disabled) {
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
    border-color: #3498db;
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(52, 152, 219, 0.3);
}

.paginazione button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

.paginazione button.active {
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
    border-color: #3498db;
}

.paginazione-info {
    margin: 0 12px;
    font-size: 0.85rem;
    color: #2c3e50;
    text-align: center;
    font-weight: 600;
}

.paginazione-config {
    display: flex;
    align-items: center;
    gap: 8px;
}

.paginazione-config label {
    font-size: 0.85rem;
    color: #2c3e50;
    font-weight: 600;
}

.paginazione-select {
    padding: 6px 10px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    background: white;
    font-size: 0.85rem;
    transition: all 0.3s ease;
}

.paginazione-select:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

/* Form commessa */
#form-commessa {
    background: rgba(248, 249, 250, 0.9);
    padding: 1.5rem;
    border-radius: 12px;
    border: 2px solid rgba(52, 152, 219, 0.2);
    margin-bottom: 1.5rem;
    display: block;
    overflow: visible;
}

#form-title {
    color: #2c3e50;
    border-bottom: 3px solid #3498db;
    padding-bottom: 0.6rem;
    margin-bottom: 1.2rem;
    font-size: 1.1rem;
    position: relative;
    top: auto;
    background: transparent;
    z-index: auto;
    padding: 0.6rem 0;
}

/* Contenuto admin */
#admin-risultati {
    background: rgba(255, 255, 255, 0.95);
    padding: 1rem;
    border-radius: 12px;
    border: 2px solid rgba(52, 152, 219, 0.1);
    max-height: 60vh;
    overflow-y: auto;
}

/* Scrollbar personalizzata */
.modal-content::-webkit-scrollbar,
#admin-risultati::-webkit-scrollbar {
    width: 8px;
}

.modal-content::-webkit-scrollbar-track,
#admin-risultati::-webkit-scrollbar-track {
    background: rgba(52, 152, 219, 0.1);
    border-radius: 4px;
}

.modal-content::-webkit-scrollbar-thumb,
#admin-risultati::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #3498db, #2980b9);
    border-radius: 4px;
}

.modal-content::-webkit-scrollbar-thumb:hover,
#admin-risultati::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #2980b9, #2573a7);
}

/* RESPONSIVE - MOBILE OTTIMIZZATO */
@media (max-width: 768px) {
    body {
        padding: 15px;
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    }

    header {
        padding: 1rem;
        margin-bottom: 15px;
    }

    header h1 {
        font-size: 1.8rem;
        flex-direction: column;
        gap: 10px;
    }

    .header-lock {
        width: 35px;
        height: 35px;
    }

    .header-lock svg {
        width: 18px;
        height: 18px;
    }

    section {
        padding: 1.5rem;
        margin-bottom: 1rem;
    }

    .search-container {
        flex-direction: column;
        gap: 0.75rem;
    }

    /* Nascondi tabella normale su mobile e mostra cards */
    #tabella-risultati table {
        display: none !important;
    }

    .commesse-cards {
        display: flex;
    }

    /* Stato badge mobile più grande */
    .stato-badge {
        min-width: 140px;
        font-size: 0.75rem;
        padding: 0.6rem 0.8rem;
    }

    /* PULSANTI AMMINISTRAZIONE MOBILE - PERFETTAMENTE ALLINEATI */
    .admin-actions {
        flex-direction: row;
        gap: 0.8rem;
        width: 100%;
        margin-bottom: 1.2rem;
        justify-content: center;
        flex-wrap: wrap;
    }

    .admin-actions button {
        flex: 1;
        min-width: 140px;
        max-width: 160px;
        width: auto;
        padding: 0.9rem 1rem;
        font-size: 0.95rem;
        margin: 0;
        height: 50px;
    }

    /* TABELLA AMMINISTRATORE MOBILE - OTTIMIZZATA */
    .admin-table {
        display: block;
        width: 100%;
        background: transparent;
        box-shadow: none;
        border: none;
        overflow: visible;
        table-layout: auto;
    }

    .admin-table thead {
        display: none;
    }

    .admin-table tbody {
        display: flex;
        flex-direction: column;
        gap: 1rem;
        overflow: visible;
        width: 100%;
    }

    .admin-table tr {
        display: flex;
        flex-direction: column;
        background: white;
        border: 1px solid #e0e0e0;
        border-radius: 12px;
        padding: 1.2rem;
        margin-bottom: 0;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
        overflow: visible;
        width: 100%;
    }

    .admin-table td {
        display: flex;
        flex-direction: column;
        width: 100% !important;
        padding: 0.8rem 0;
        border: none;
        border-bottom: 1px solid #f0f0f0;
        text-align: left;
        overflow: visible;
        word-break: break-word;
        hyphens: auto;
    }

    .admin-table td:last-child {
        border-bottom: none;
        padding-bottom: 0;
    }

    .admin-table td:first-child {
        padding-top: 0;
    }

    /* ETICHETTE MOBILE PER TABELLA AMMINISTRATORE */
    .admin-table td::before {
        content: attr(data-label);
        display: block;
        font-weight: 700;
        color: #2c3e50;
        font-size: 0.85rem;
        margin-bottom: 0.3rem;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        width: 100%;
    }

    .admin-table td:nth-child(1)::before { content: "CODICE CLIENTE"; }
    .admin-table td:nth-child(2)::before { content: "CODICE COMMESSA"; }
    .admin-table td:nth-child(3)::before { content: "DESCRIZIONE"; }
    .admin-table td:nth-child(4)::before { content: "STATO"; }
    .admin-table td:nth-child(5)::before { content: "PREV. CONSEGNA"; }
    .admin-table td:nth-child(6)::before { content: "NOTE"; }
    .admin-table td:nth-child(7)::before { content: "AZIONI"; }

    /* STATO MOBILE - OTTIMIZZATO */
    .admin-table td:nth-child(4) {
        padding: 1rem 0;
    }

    .admin-table td:nth-child(4) .stato-badge {
        display: inline-block;
        min-width: 150px;
        width: auto;
        margin-top: 0.5rem;
        font-size: 0.8rem;
        padding: 0.7rem 1rem;
        max-width: 100%;
    }

    /* PULSANTI AZIONI MOBILE - AFFIANCATI ORIZZONTALMENTE */
    .btn-actions {
        flex-direction: row;
        gap: 0.5rem;
        width: 100%;
        justify-content: center;
        margin-top: 0.5rem;
        flex-wrap: nowrap;
    }

    .btn-modifica, .btn-elimina {
        flex: 1;
        min-width: 100px;
        max-width: 120px;
        padding: 0.7rem 0.5rem;
        font-size: 0.8rem;
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .modal-content {
        width: 95%;
        margin: 5% auto;
        padding: 1.5rem;
        border-radius: 15px;
        max-height: 85vh;
        overflow-y: auto;
    }

    .admin-content {
        max-width: 98% !important;
        width: 98% !important;
        margin: 1% auto !important;
        padding: 1rem;
        max-height: 95vh;
        overflow-y: auto;
    }

    .form-buttons {
        flex-direction: column;
    }

    /* Contenuto admin mobile - OTTIMIZZATO */
    #admin-risultati {
        overflow: visible;
        max-height: none;
        padding: 0.5rem;
    }

    /* Tooltip responsive */
    .tooltip-text {
        width: 200px;
        font-size: 0.8rem;
        padding: 10px;
    }

    h2 {
        flex-wrap: wrap;
        font-size: 1.2rem;
    }

    /* Paginazione mobile */
    .paginazione {
        flex-direction: column;
        gap: 15px;
        text-align: center;
        padding: 15px;
    }

    .paginazione-controls {
        justify-content: center;
    }

    .paginazione-info {
        margin: 10px 0;
        order: -1;
    }

    .paginazione-config {
        justify-content: center;
        flex-wrap: wrap;
    }

    .close {
        right: 1rem;
        top: 1rem;
        font-size: 28px;
    }

    /* Migliora la visualizzazione dei contenuti lunghi */
    .admin-table td {
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    /* FORM MOBILE - OTTIMIZZATO */
    #form-commessa {
        max-height: none;
        overflow: visible;
        padding: 1rem;
    }

    /* CORREZIONE: Spazio login mobile */
    #login-form input[type="password"] {
        margin-bottom: 0.8rem !important;
    }
}

/* REGOLE AGGIUNTIVE PER SCHERMI MOLTO PICCOLI */
@media (max-width: 480px) {
    .admin-actions {
        flex-direction: column;
        gap: 0.6rem;
    }

    .admin-actions button {
        min-width: 100%;
        max-width: 100%;
        width: 100%;
        padding: 0.9rem 1rem;
        font-size: 0.9rem;
        height: 45px;
    }

    .btn-actions {
        flex-direction: row;
        gap: 0.4rem;
    }

    .btn-modifica, .btn-elimina {
        min-width: 90px;
        max-width: 110px;
        font-size: 0.75rem;
        padding: 0.6rem 0.4rem;
        height: 38px;
    }

    .admin-table tr {
        padding: 1rem;
    }

    .admin-table td {
        padding: 0.6rem 0;
    }

    .admin-content {
        padding: 0.8rem;
    }

    .admin-table td::before {
        font-size: 0.8rem;
    }

    .modal-content {
        padding: 1rem;
        margin: 2% auto;
    }

    section {
        padding: 1rem;
    }

    /* CORREZIONE: Spazio login mobile piccolo */
    #login-form input[type="password"] {
        margin-bottom: 0.6rem !important;
    }
}

@media (min-width: 769px) {
    .commesse-cards {
        display: none !important;
    }

    #tabella-risultati table {
        display: table !important;
    }
}

footer {
    text-align: center;
    margin-top: 30px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    color: #2c3e50;
    border-radius: 15px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
}
