/* ===== RESET E VARIABILI ===== */
:root {
    --primary-color: #3498db;
    --secondary-color: #2c3e50;
    --success-color: #27ae60;
    --warning-color: #f39c12;
    --danger-color: #e74c3c;
    --info-color: #17a2b8;
    
    --gradient-primary: linear-gradient(135deg, #3498db, #2c3e50);
    --gradient-stats: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-scroll-top: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-scroll-bottom: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    
    --text-dark: #2c3e50;
    --text-medium: #5a6c7d;
    --text-light: #7f8c8d;
    --text-muted: #95a5a6;
    
    --bg-light: #f5f5f5;
    --bg-white: #ffffff;
    --bg-gray: #f8f9fa;
    --border-color: #e1e8ed;
    --shadow-light: 0 2px 10px rgba(0,0,0,0.1);
    --shadow-medium: 0 4px 15px rgba(0,0,0,0.1);
    --shadow-heavy: 0 8px 25px rgba(0,0,0,0.2);
    
    --border-radius: 10px;
    --border-radius-sm: 6px;
    --transition: all 0.3s ease;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-light);
    color: var(--text-dark);
    line-height: 1.6;
    background: 
        linear-gradient(rgba(131, 129, 129, 0.4), rgba(146, 145, 145, 0.4)),
        url('../imm/bg.jpg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
    margin: 0;
    padding: 0;
    min-height: 100vh;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.615); /* Oscuramento */
    backdrop-filter: blur(3px); /* Leggera sfocatura */
    z-index: -1;
}
/* ===== CUSTOM ALERTS STYLES ===== */
.custom-alert-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 20px;
    animation: fadeIn 0.3s ease;
}

.custom-alert {
    background: var(--bg-white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-heavy);
    width: 100%;
    max-width: 400px;
    animation: slideInDown 0.3s ease;
    overflow: hidden;
}

.custom-alert-success {
    border-top: 4px solid var(--success-color);
}

.custom-alert-error {
    border-top: 4px solid var(--danger-color);
}

.custom-alert-warning {
    border-top: 4px solid var(--warning-color);
}

.custom-alert-info {
    border-top: 4px solid var(--info-color);
}

.custom-alert-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 20px 0 20px;
    margin-bottom: 15px;
}

.custom-alert-icon {
    font-size: 1.5em;
    flex-shrink: 0;
}

.custom-alert-title {
    color: var(--text-dark);
    font-size: 1.2em;
    font-weight: 600;
    margin: 0;
}

.custom-alert-body {
    padding: 0 20px;
    color: var(--text-medium);
    line-height: 1.5;
    margin-bottom: 20px;
}

.custom-alert-footer {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding: 15px 20px 20px 20px;
    background: var(--bg-gray);
    border-top: 1px solid var(--border-color);
}

.custom-alert-btn {
    padding: 10px 20px;
    border: none;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    font-size: 0.9em;
    font-weight: 500;
    transition: var(--transition);
    min-width: 80px;
    text-align: center;
}

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

.custom-alert-btn-primary:hover {
    background-color: #2980b9;
    transform: translateY(-1px);
}

.custom-alert-btn-secondary {
    background-color: var(--bg-white);
    color: var(--text-dark);
    border: 1px solid var(--border-color);
}

.custom-alert-btn-secondary:hover {
    background-color: var(--bg-gray);
    border-color: var(--text-light);
}

/* ===== LAYOUT PRINCIPALE ===== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 15px;
}

/* ===== HEADER MOBILE FRIENDLY ===== */
.header {
    background: var(--gradient-primary);
    color: white;
    padding: 15px;
    border-radius: var(--border-radius);
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    text-align: center;
}

.header-top {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    width: 100%;
}

.header h1 {
    font-size: clamp(1.4em, 4vw, 2em);
    font-weight: 300;
    margin: 0;
    line-height: 1.2;
}

.logo-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    width: 100%;
}

/* Logo dimensioni controllate */
.logo-section img {
    max-width: 100px;
    height: auto;
    width: auto;
    max-height: 50px;
    object-fit: contain;
}

/* ===== PULSANTE AZIENDA MOBILE ===== */
.btn-azienda-header {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 16px;
    cursor: pointer;
    font-size: 0.75em;
    transition: var(--transition);
    color: var(--text-dark);
    font-weight: 500;
    white-space: nowrap;
    min-height: 28px;
    text-decoration: none;
}

.btn-azienda-header:hover {
    background: white;
    border-color: white;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

/* ===== STATUS INDICATORS MOBILE ===== */
.compact-status {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    width: 100%;
}

.header-status {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    width: 100%;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8em;
    color: white;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--text-muted);
    animation: pulse 2s infinite;
}

.status-dot.connected {
    background-color: var(--success-color);
    animation: none;
}

.status-dot.disconnected {
    background-color: var(--danger-color);
    animation: none;
}

.services-indicator {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 4px 10px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 16px;
    cursor: pointer;
    font-size: 0.75em;
    transition: var(--transition);
    min-height: 28px;
    text-decoration: none;
    color: var(--text-dark);
}

.services-indicator:hover {
    background: white;
    border-color: white;
    transform: translateY(-1px);
}

.indicator-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-muted);
}

.indicator-dot.connected { background: var(--success-color); }
.indicator-dot.disconnected { background: var(--danger-color); }
.indicator-dot.warning { background: var(--warning-color); }
.indicator-dot.checking { 
    background: var(--warning-color);
    animation: pulse 1.5s infinite;
}

.indicator-text {
    font-weight: 500;
    color: var(--text-dark);
}

.indicator-badge {
    background: var(--primary-color);
    color: white;
    padding: 1px 4px;
    border-radius: 8px;
    font-size: 0.65em;
    min-width: 16px;
    text-align: center;
    line-height: 1;
}

/* ===== NAVIGATION TABS MOBILE ===== */
.tabs {
    display: flex;
    background: var(--bg-white);
    border-radius: var(--border-radius);
    margin-bottom: 15px;
    overflow-x: auto;
    box-shadow: var(--shadow-light);
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

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

.tab-btn {
    flex: 1;
    padding: 10px 8px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 0.8em;
    transition: var(--transition);
    white-space: nowrap;
    min-width: 70px;
    min-height: 40px;
}

.tab-btn:hover {
    background-color: var(--bg-gray);
}

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

/* ===== CONTENT AREAS MOBILE ===== */
.content {
    background: var(--bg-white);
    border-radius: var(--border-radius);
    padding: 15px;
    box-shadow: var(--shadow-light);
    margin-bottom: 15px;
}

.tab-content {
    display: none;
}

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

/* ===== DASHBOARD STATS MOBILE ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--gradient-stats);
    color: white;
    padding: 15px 10px;
    border-radius: var(--border-radius);
    text-align: center;
    box-shadow: var(--shadow-medium);
}

.stat-card h3 {
    font-size: 1.5em;
    margin-bottom: 4px;
    line-height: 1.2;
    font-weight: 600;
}

.stat-card p {
    opacity: 0.9;
    font-size: 0.8em;
    margin: 0;
}

/* ===== BUTTONS MOBILE ===== */
.actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 8px;
    margin-bottom: 15px;
}

.btn {
    padding: 10px 12px;
    border: none;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    font-size: 0.85em;
    font-weight: 500;
    transition: var(--transition);
    text-align: center;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    word-break: break-word;
    line-height: 1.3;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-medium);
}

.btn-primary { background-color: var(--primary-color); color: white; }
.btn-secondary { background-color: var(--secondary-color); color: white; }
.btn-success { background-color: var(--success-color); color: white; }
.btn-info { background-color: var(--info-color); color: white; }
.btn-warning { background-color: var(--warning-color); color: white; }
.btn-danger { background-color: var(--danger-color); color: white; }

.btn-sm {
    padding: 6px 10px;
    font-size: 0.75em;
    min-height: 30px;
}

/* ===== SECTION HEADERS MOBILE ===== */
.section-header {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 15px;
}

.section-header h2 {
    color: var(--text-dark);
    font-size: 1.2em;
    text-align: center;
    margin: 0;
}

.search-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: stretch;
    width: 100%;
}

.search-container input {
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.9em;
    min-height: 40px;
    width: 100%;
}

/* ===== ENTITY LISTS MOBILE ===== */
.list-container {
    min-height: 150px;
}

.loading {
    text-align: center;
    padding: 30px 15px;
    color: var(--text-light);
    font-style: italic;
    font-size: 0.9em;
}

.entity-card {
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 12px;
    margin-bottom: 10px;
    transition: var(--transition);
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.entity-card:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-medium);
}

.entity-header {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 8px;
}

.entity-title {
    font-size: 1em;
    font-weight: 600;
    color: var(--text-dark);
    line-height: 1.3;
    margin: 0;
}

.entity-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.entity-details {
    color: var(--text-light);
    line-height: 1.5;
    font-size: 0.85em;
    margin: 0;
}

.entity-detail {
    margin-bottom: 3px;
}

.entity-meta {
    font-size: 0.75em;
    color: var(--text-muted);
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid #ecf0f1;
}

/* ===== MODALS MOBILE ===== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    display: none;
    z-index: 1000;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 10px;
}

.modal-content {
    background-color: var(--bg-white);
    margin: 5vh auto;
    border-radius: var(--border-radius);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-heavy);
    animation: modalSlideIn 0.3s ease-out;
}

.modal-header {
    background: var(--gradient-primary);
    color: white;
    padding: 12px 15px;
    border-radius: var(--border-radius) var(--border-radius) 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 10;
}

.modal-header h3 {
    margin: 0;
    font-weight: 500;
    font-size: 1em;
}

.close {
    font-size: 1.2em;
    cursor: pointer;
    transition: opacity 0.3s;
    background: none;
    border: none;
    color: white;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    padding: 0;
}

.close:hover {
    opacity: 0.7;
}

/* ===== FORMS MOBILE ===== */
.modal form {
    padding: 15px;
}

.form-group {
    margin-bottom: 12px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: var(--text-dark);
    font-size: 0.85em;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.9em;
    transition: var(--transition);
    min-height: 40px;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.1);
}

.form-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 15px;
    padding-top: 12px;
    border-top: 1px solid #e2e8f0;
}

/* Form azienda mobile */
#aziendaForm {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* ===== SERVICES POPUP MOBILE ===== */
/* Services Popup */
.services-popup {
    display: none;
    position: absolute;
    top: 100%;
    right: 1rem;
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    z-index: 1001;
    min-width: 300px;
    max-width: 400px;
}

.services-popup.show {
    display: block;
}

.popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid #eee;
    background: #f8f9fa;
}

.popup-header h4 {
    margin: 0;
    color: #2c3e50;
}

.btn-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #7f8c8d;
}

.btn-close:hover {
    color: #e74c3c;
}

.services-mini-grid {
    padding: 1rem;
}

.mini-service {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid #f1f1f1;
}

.mini-service:last-child {
    border-bottom: none;
}

.mini-service-name {
    font-weight: 500;
    color: #2c3e50;
}

.mini-service-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
}

.popup-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border-top: 1px solid #eee;
    background: #f8f9fa;
    font-size: 0.8rem;
}

.btn-refresh {
    background: #3498db;
    color: white;
    border: none;
    padding: 0.3rem 0.7rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
}

.btn-refresh:hover {
    background: #2980b9;
}

/* Services Indicator */
.services-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.8rem;
    background: rgba(255,255,255,0.1);
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.3s ease;
}

.services-indicator:hover {
    background: rgba(255,255,255,0.2);
}

.indicator-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.indicator-dot.connected {
    background: #27ae60;
}

.indicator-dot.checking {
    background: #f39c12;
    animation: pulse 1.5s infinite;
}

.indicator-dot.disconnected {
    background: #e74c3c;
}

.indicator-dot.warning {
    background: #f39c12;
}

.indicator-text {
    color: white;
    font-size: 0.9rem;
}

.indicator-badge {
    background: rgba(255,255,255,0.2);
    color: white;
    padding: 0.1rem 0.4rem;
    border-radius: 10px;
    font-size: 0.8rem;
    font-weight: 600;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

/* ===== PULSANTI SCROLL MOBILE OPTIMIZED ===== */
.scroll-buttons {
    position: fixed;
    right: 10px;
    bottom: 10px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 6px;
    animation: fadeInUp 0.5s ease-out;
}

.scroll-btn {
    width: 38px;
    height: 38px;
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    touch-action: manipulation;
}

.scroll-btn:hover {
    transform: translateY(-1px) scale(1.05);
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.2);
}

.scroll-btn:active {
    transform: translateY(0) scale(0.98);
    transition: all 0.1s ease;
}

/* Pulsante Scroll to Top */
.scroll-to-top {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: 1px solid rgba(255,255,255,0.1);
}

/* Pulsante Scroll to Bottom */
.scroll-to-bottom {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    border: 1px solid rgba(255,255,255,0.1);
}

/* Nascondi tooltip su mobile */
.scroll-btn .tooltip {
    display: none;
}

/* ===== UTILITY CLASSES ===== */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }
.mt-1 { margin-top: 8px; }
.mb-1 { margin-bottom: 8px; }
.mt-2 { margin-top: 12px; }
.mb-2 { margin-bottom: 12px; }
.d-none { display: none !important; }
.d-block { display: block !important; }
.d-flex { display: flex !important; }

/* ===== RESPONSIVE BREAKPOINTS ===== */

/* Tablet (768px e sopra) */
@media (min-width: 768px) {
    .container {
        padding: 20px;
    }
    
    .custom-alert {
        max-width: 450px;
    }
    
    .custom-alert-header {
        padding: 25px 25px 0 25px;
    }
    
    .custom-alert-body {
        padding: 0 25px;
    }
    
    .custom-alert-footer {
        padding: 20px 25px 25px 25px;
    }
    
    .header {
        flex-direction: row;
        text-align: left;
        padding: 20px 25px;
        align-items: center;
        justify-content: space-between;
        gap: 15px;
    }
    
    .header-top {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        width: auto;
        gap: 15px;
    }
    
    .logo-section {
        flex-direction: row;
        align-items: center;
        gap: 12px;
        width: auto;
    }
    
    .logo-section img {
        max-width: 120px;
        max-height: 60px;
    }
    
    .btn-azienda-header {
        margin: 0;
        width: auto;
        font-size: 0.8em;
        padding: 6px 12px;
    }
    
    .compact-status {
        flex-direction: row;
        width: auto;
        gap: 12px;
    }
    
    .header-status {
        justify-content: flex-end;
        width: auto;
    }
    
    .services-indicator {
        margin: 0;
        width: auto;
        font-size: 0.8em;
        padding: 4px 10px;
    }
    
    .connection-status {
        font-size: 0.8em;
    }
    
    .section-header {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        text-align: left;
        gap: 15px;
    }
    
    .section-header h2 {
        text-align: left;
        font-size: 1.4em;
        margin: 0;
    }
    
    .search-container {
        flex-direction: row;
        width: auto;
        gap: 10px;
    }
    
    .search-container input {
        min-width: 200px;
        min-height: 40px;
    }
    
    .entity-header {
        flex-direction: row;
        justify-content: space-between;
        align-items: flex-start;
        gap: 15px;
    }
    
    .form-actions {
        flex-direction: row;
        gap: 10px;
    }
    
    #aziendaForm {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }
    
    #aziendaForm .form-group:first-child,
    #aziendaForm .form-actions {
        grid-column: 1 / -1;
    }
    
    .scroll-buttons {
        right: 15px;
        bottom: 15px;
        gap: 8px;
    }
    
    .scroll-btn {
        width: 42px;
        height: 42px;
        font-size: 16px;
    }
    
    .services-popup {
        position: absolute;
        top: 70px;
        right: 15px;
        left: auto;
        transform: none;
        width: auto;
        min-width: 220px;
        padding: 15px;
    }
    
    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        gap: 15px;
    }
    
    .stat-card {
        padding: 18px 12px;
    }
    
    .stat-card h3 {
        font-size: 1.7em;
    }
    
    .actions {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        gap: 10px;
    }
    
    .btn {
        padding: 12px 14px;
        font-size: 0.9em;
        min-height: 44px;
    }
}

/* Desktop (992px e sopra) */
@media (min-width: 992px) {
    .header {
        padding: 25px 30px;
    }
    
    .logo-section img {
        max-width: 140px;
        max-height: 70px;
    }
    
    .btn-azienda-header,
    .services-indicator {
        font-size: 0.85em;
        padding: 8px 14px;
        min-height: 32px;
    }
    
    #aziendaForm {
        grid-template-columns: 1fr 1fr 1fr;
        gap: 15px;
    }
    
    #aziendaForm .form-group:nth-child(1) {
        grid-column: 1 / 3;
    }
    
    #aziendaForm .form-group:nth-child(2) {
        grid-column: 3 / 4;
    }
    
    .scroll-buttons {
        right: 20px;
        bottom: 20px;
    }
    
    .scroll-btn {
        width: 46px;
        height: 46px;
        font-size: 17px;
    }
    
    .scroll-btn .tooltip {
        display: block;
        position: absolute;
        right: 55px;
        background: var(--text-dark);
        color: white;
        padding: 6px 10px;
        border-radius: 6px;
        font-size: 0.7em;
        font-weight: 500;
        white-space: nowrap;
        opacity: 0;
        transform: translateX(10px);
        transition: all 0.3s ease;
        pointer-events: none;
        box-shadow: 0 3px 10px rgba(0,0,0,0.15);
    }
    
    .scroll-btn:hover .tooltip {
        opacity: 1;
        transform: translateX(0);
    }
    
    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
        gap: 20px;
    }
    
    .stat-card {
        padding: 20px 15px;
    }
    
    .stat-card h3 {
        font-size: 1.9em;
    }
}

/* Schermi molto piccoli (480px e sotto) */
@media (max-width: 480px) {
    .container {
        padding: 10px;
    }
    
    .custom-alert-overlay {
        padding: 15px;
    }
    
    .custom-alert-header {
        padding: 15px 15px 0 15px;
        gap: 10px;
    }
    
    .custom-alert-title {
        font-size: 1.1em;
    }
    
    .custom-alert-body {
        padding: 0 15px;
        font-size: 0.9em;
    }
    
    .custom-alert-footer {
        padding: 15px 15px 15px 15px;
        flex-direction: column;
    }
    
    .custom-alert-btn {
        min-width: auto;
        width: 100%;
    }
    
    .header {
        padding: 12px;
        gap: 10px;
    }
    
    .logo-section img {
        max-width: 90px;
        max-height: 45px;
    }
    
    .btn-azienda-header,
    .services-indicator {
        font-size: 0.7em;
        padding: 5px 8px;
        min-height: 26px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .actions {
        grid-template-columns: 1fr;
        gap: 6px;
    }
    
    .btn {
        min-height: 38px;
        padding: 8px 10px;
        font-size: 0.8em;
    }
    
    .entity-card {
        padding: 10px;
    }
    
    .scroll-buttons {
        right: 8px;
        bottom: 38px;
        gap: 5px;
    }
    
    .scroll-btn {
        width: 36px;
        height: 36px;
        font-size: 13px;
        border-radius: 6px;
    }
    
    .modal {
        padding: 5px;
    }
    
    .modal-content {
        margin: 2vh auto;
    }
    
    .tab-btn {
        min-width: 60px;
        font-size: 0.75em;
        padding: 8px 6px;
    }
}

/* ===== ANIMATIONS ===== */
@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

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

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

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(15px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes slideInDown {
    from {
        opacity: 0;
        transform: translateY(-30px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Scrollbar personalizzata */
.modal-content::-webkit-scrollbar {
    width: 4px;
}

.modal-content::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 2px;
}

.modal-content::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 2px;
}

.modal-content::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}


/* ===== BARRA INFORMATIVA DISPOSITIVO ===== */
.compact-info-bar {
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    padding: 4px 0;
    font-size: 10px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.info-grid {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    max-width: 100%;
}

.info-cell {
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.info-label {
    font-weight: 600;
    color: #495057;
    opacity: 0.8;
}

.info-value {
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', monospace;
    background: #ffffff;
    border: 1px solid #e9ecef;
    padding: 1px 6px;
    border-radius: 3px;
    color: #2c3e50;
    font-size: 9px;
    font-weight: 500;
}

/* Responsive per schermi piccoli */
@media (max-width: 768px) {
    .info-grid {
        gap: 8px;
    }
    
    .info-cell {
        font-size: 8px;
    }
}


/* Stili per gli stati dell'IP nella info-bar */
.info-value.loading {
    color: #666;
    font-style: italic;
}

.info-value.success {
    color: #28a745;
    font-weight: bold;
}

.info-value.error {
    color: #dc3545;
}



/* Gestione Controparte */
.gestione-controparte-content {
    padding: 1rem;
}

.controparte-info-card {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1.5rem;
}

.controparte-info-card h4 {
    margin: 0 0 1rem 0;
    color: #2c3e50;
}

.controparte-details div {
    margin-bottom: 0.5rem;
    display: flex;
    gap: 0.5rem;
}

.controparte-details strong {
    min-width: 120px;
    color: #34495e;
}

/* Tabs Gestione */
.gestione-tabs {
    display: flex;
    border-bottom: 2px solid #e9ecef;
    margin-bottom: 1.5rem;
}

.gestione-tab-btn {
    background: none;
    border: none;
    padding: 0.75rem 1.5rem;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.3s ease;
    color: #6c757d;
    font-weight: 500;
}

.gestione-tab-btn.active {
    color: #3498db;
    border-bottom-color: #3498db;
    background: #f8f9fa;
}

.gestione-tab-btn:hover {
    color: #2980b9;
    background: #f8f9fa;
}

.gestione-tab-content {
    display: none;
}

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

/* Scadenze */
.scadenze-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.scadenze-list {
    max-height: 300px;
    overflow-y: auto;
}

.scadenza-item {
    display: flex;
    align-items: center;
    padding: 1rem;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    margin-bottom: 0.5rem;
    background: #fff;
    transition: all 0.3s ease;
}

.scadenza-item:hover {
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.scadenza-icon {
    font-size: 1.5rem;
    margin-right: 1rem;
}

.scadenza-info {
    flex: 1;
}

.scadenza-descrizione {
    font-weight: 500;
    color: #2c3e50;
    margin-bottom: 0.25rem;
}

.scadenza-dettagli {
    display: flex;
    gap: 1rem;
    font-size: 0.9rem;
    color: #6c757d;
}

.scadenza-importo {
    font-weight: 600;
    color: #27ae60;
}

.scadenza-stato {
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
}

.nuova-scadenza-form {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 1rem;
    margin-top: 1rem;
}

.nuova-scadenza-form h5 {
    margin: 0 0 1rem 0;
    color: #2c3e50;
}

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

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

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

.form-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid #e9ecef;
}

/* ===== COLORI TIPO CONTRORPARTE ===== */
.controparte-cliente { color: #3498db; }
.controparte-fornitore { color: #e74c3c; }
.controparte-azienda { color: #9b59b6; }
.controparte-atleta { color: #e67e22; }
.controparte-agente { color: #1abc9c; }
.controparte-tavolo { color: #34495e; }
.controparte-studente { color: #2ecc71; }
.controparte-professore { color: #f39c12; }
.controparte-cassa { color: #d35400; }
.controparte-banca { color: #16a085; }
.controparte-risorsa { color: #8e44ad; }
.controparte-deposito { color: #7f8c8d; }
.controparte-vettore { color: #c0392b; }
.controparte-altro { color: #95a5a6; }

/* Badge tipo controparte */
.tipo-badge {
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 0.7em;
    font-weight: 600;
    text-transform: uppercase;
    display: inline-block;
    margin-left: 8px;
}

/* Colori movimento */
.movimento-scarico { color: #27ae60; font-weight: 600; }
.movimento-carico { color: #e74c3c; font-weight: 600; }


.form-columns {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
}

.form-column {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

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

.form-group label {
    margin-bottom: 5px;
    font-weight: bold;
}

.form-group input,
.form-group select {
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.btn-primary {
    background-color: #007bff;
    color: white;
}

.btn-secondary {
    background-color: #6c757d;
    color: white;
}

/* ENTITY CARD */
.entity-card.disabled {
    opacity: 0.6;
    background-color: #f5f5f5;
}

.entity-card.disabled .entity-title,
.entity-card.disabled .entity-detail,
.entity-card.disabled .entity-meta {
    color: #666;
}

/* I pulsanti mantengono i loro colori originali */
.entity-card.disabled .entity-actions {
    opacity: 1; /* Sovrascrive l'opacità della card solo per i pulsanti */
}

.entity-card.disabled .btn {
    pointer-events: auto;
    filter: none;
}



.switch-container {
    display: flex;
    align-items: center;
    margin-right: 10px;
}

.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
    margin-right: 8px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
}

input:checked + .slider {
    background-color: #2196F3;
}

input:checked + .slider:before {
    transform: translateX(26px);
}

.slider.round {
    border-radius: 24px;
}

.slider.round:before {
    border-radius: 50%;
}

.switch-label {
    font-size: 12px;
    color: #666;
    min-width: 60px;
}




/* ===== STATUS BAR STYLES ===== */
.status-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #2c3e50;
    color: white;
    padding: 8px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    border-top: 2px solid #3498db;
    z-index: 1000;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.3);
}

.status-left, .status-center, .status-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.status-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

.status-badge {
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 8px;
    font-weight: normal;
}

.status-connected {
    background: #27ae60;
}

.status-disconnected {
    background: #e74c3c;
}

.status-warning {
    background: #f39c12;
}

/* Aggiusta il padding del container principale per evitare sovrapposizione */
.container {
    padding-bottom: 50px;
}

/* Responsive */
@media (max-width: 768px) {
    .status-bar {
        flex-direction: column;
        gap: 5px;
        padding: 5px 10px;
    }
    
    .status-left, .status-center, .status-right {
        gap: 10px;
    }
    
    .status-item {
        font-size: 8px;
    }
}

/* Overlay per sfondo */
.overlay-segreto {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    display: none;
}

.overlay-segreto.visibile {
    display: block;
}


/* Container pulsanti segreti */
.pulsanti-segreti-container {
    position: fixed;
    bottom: 40px;
    left: 20px;  /* MODIFICATO: da right a left */
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 1000;
}

/* Pulsanti Area Segreta */
.pulsante-segreto {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, #002fff 0%, #486298 100%);
    border: 2px solid #fff;
    color: white;
    font-size: 20px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
    display: flex !important;
    align-items: center;
    justify-content: center;
}

.pulsante-segreto:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

.pulsante-segreto:active {
    transform: scale(0.95);
}

/* Header area segreta */
.segreta-header {
    text-align: center;
    margin-bottom: 20px;
    border-bottom: 1px solid #eee;
    padding-bottom: 15px;
}

.pulsanti-sezioni {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 15px;
    flex-wrap: wrap;
}

.btn-sezione {
    padding: 8px 16px;
    border: 1px solid #007bff;
    background: white;
    color: #007bff;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-sezione:hover {
    background: #f8f9fa;
}

.btn-sezione.active {
    background: #007bff;
    color: white;
}

.contenuto-dinamico {
    max-height: 60vh;
    overflow-y: auto;
    padding: 10px;
}

/* Stili esistenti rimangono uguali... */
.area-nascosta {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.98);
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.4);
    z-index: 10000;
    min-width: 80%;
    max-width: 90%;
    max-height: 90vh;
    border: 2px solid #007bff;
}

.area-nascosta.visibile {
    display: block;
}

.overlay-segreto {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 9999;
    display: none;
}

.overlay-segreto.visibile {
    display: block;
}

.btn-chiudi {
    background: #dc3545;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    margin-top: 20px;
    width: 100%;
    transition: background 0.3s ease;
}

.btn-chiudi:hover {
    background: #c82333;
}

/* Fine del file style.css */
