/* ==========================================================================
   MOBILE-FIRST CSS - UILTRASPORTI ENAV
   ========================================================================== */

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

/* CSS Variables */
:root {
    --primary-color: #2c5282;
    --secondary-color: #4a5568;
    --success-color: #38a169;
    --danger-color: #e53e3e;
    --warning-color: #dd6b20;
    --info-color: #3182ce;
    --bg-color: #f7fafc;
    --card-bg: #ffffff;
    --text-color: #2d3748;
    --border-color: #e2e8f0;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Body - Mobile First */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body.menu-open {
    overflow: hidden;
}

/* ==========================================================================
   LOGIN PAGE
   ========================================================================== */

body.login-page {
    background: linear-gradient(135deg, #2c5282 0%, #1a365d 100%);
}

.login-card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    padding: 2.5rem 2rem;
    width: 100%;
    max-width: 400px;
    margin: 0 1rem;
}

.login-card h1 {
    font-size: 1.75rem;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
    text-align: center;
}

.login-card h2 {
    font-size: 1.1rem;
    color: var(--secondary-color);
    margin-bottom: 1.5rem;
    text-align: center;
    font-weight: 400;
}

.login-card .form-group {
    margin-bottom: 1.25rem;
}

.login-card .btn {
    width: 100%;
    margin-top: 1rem;
}

/* ==========================================================================
   NAVBAR - MOBILE FIRST
   ========================================================================== */

.navbar {
    background: linear-gradient(135deg, var(--primary-color) 0%, #2563eb 100%);
    color: white;
    position: sticky;
    top: 0;
    z-index: 10001;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    backdrop-filter: blur(10px);
}

.nav-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    position: relative;
}

.nav-brand h2 {
    font-size: 1.4rem;
    margin: 0;
    font-weight: 700;
    letter-spacing: -0.5px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.nav-brand-row {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.nav-brand-link {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: inherit;
}

.nav-brand-logo {
    max-height: 50px;
    max-width: 180px;
    cursor: pointer;
}

.nav-subtitle {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    white-space: nowrap;
    margin-top: 0.3rem;
    display: none;
}

/* Burger Menu - Mobile */
.burger-menu {
    display: flex;
    flex-direction: column;
    gap: 5px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    cursor: pointer;
    padding: 10px;
    border-radius: 8px;
    z-index: 10000;
    transition: all 0.3s ease;
}

.burger-menu:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

.burger-menu span {
    display: block;
    width: 25px;
    height: 3px;
    background: white;
    border-radius: 3px;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.burger-menu.active span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.burger-menu.active span:nth-child(2) {
    opacity: 0;
}

.burger-menu.active span:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -6px);
}

/* Nav Menu - Mobile */
.nav-menu {
    position: fixed;
    top: 0;
    left: -100%;
    width: 300px;
    height: 100vh;
    background: linear-gradient(180deg, var(--primary-color) 0%, #1e40af 100%);
    display: flex;
    flex-direction: column;
    padding-top: 85px;
    transition: left 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    z-index: 10002;
    overflow-y: auto;
    box-shadow: 4px 0 30px rgba(0, 0, 0, 0.4);
}

.nav-menu.active {
    left: 0;
}

.nav-links {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0.75rem 0;
    gap: 2px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    color: white;
    text-decoration: none;
    padding: 0.65rem 1rem;
    margin: 0 0.5rem;
    border-radius: 8px;
    transition: all 0.3s ease;
    font-size: 0.875rem;
    font-weight: 500;
    position: relative;
    overflow: hidden;
}

.nav-link::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 4px;
    background: white;
    transform: scaleY(0);
    transition: transform 0.3s ease;
}

.nav-link:hover,
.nav-link.active {
    background-color: rgba(255, 255, 255, 0.15);
    transform: translateX(5px);
    box-shadow: none;
    color: white !important;
}

.nav-link:hover::before,
.nav-link.active::before {
    transform: scaleY(1);
}

/* Sottosezioni */
.nav-sublink {
    display: flex;
    align-items: center;
    gap: 14px;
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    padding: 0.75rem 1.5rem 0.75rem 2.5rem;
    margin: 0 0.75rem;
    border-radius: 12px;
    transition: all 0.3s ease;
    font-size: 0.925rem;
    font-weight: 400;
    position: relative;
    background: rgba(0, 0, 0, 0.1);
}

.nav-sublink:hover,
.nav-sublink.active {
    background-color: rgba(255, 255, 255, 0.2);
    color: white !important;
    transform: translateX(5px);
}

.nav-icon {
    font-size: 1.35rem;
    width: 28px;
    text-align: center;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

/* Nav User Section - Mobile */
.nav-user-top {
    border-bottom: 2px solid rgba(255, 193, 7, 0.5);
    padding: 0.6rem 0.75rem;
    background: linear-gradient(135deg, rgba(255, 152, 0, 0.25), rgba(255, 193, 7, 0.2));
    margin-bottom: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    order: -1;
}

.nav-user-top .nav-link {
    background: rgba(255, 255, 255, 0.15);
    border-left: 3px solid #ffc107;
    font-weight: 600;
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
}

.nav-user-top .nav-link:hover {
    background: rgba(255, 255, 255, 0.25);
    border-left-color: #ff9800;
}


.nav-links {
    order: 0;
}

.nav-user {
    border-top: 1px solid rgba(255, 255, 255, 0.15);
    padding: 1.25rem 0;
    background: rgba(0, 0, 0, 0.1);
}

.nav-profile {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 1rem 1.5rem;
    margin: 0 0.75rem;
    border-radius: 12px;
    transition: all 0.3s ease;
}

.nav-profile:hover {
    background: rgba(255, 255, 255, 0.1);
}

.user-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.user-email {
    font-size: 0.95rem;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.user-role {
    font-size: 0.75rem;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.25), rgba(255, 255, 255, 0.15));
    padding: 3px 10px;
    border-radius: 16px;
    display: inline-block;
    margin-top: 2px;
    width: fit-content;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.nav-logout {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 1rem 1.5rem;
    margin: 0 0.75rem;
    border-radius: 12px;
    transition: all 0.3s ease;
}

.nav-logout:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Company Selector in Brand Section */
.company-selector-wrapper-brand {
    display: flex;
    align-items: center;
    margin-top: 0.5rem;
}

.company-selector-brand {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.4);
    color: white;
    padding: 0.4rem 0.65rem;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
    max-width: 180px;
}

/* Mobile: logo più grande, selector accanto al logo */
@media (max-width: 768px) {
    .nav-brand-row {
        flex-direction: row;
        align-items: center;
        gap: 10px;
        justify-content: flex-start;
        margin-right: 1rem;
    }
    
    .nav-brand-logo {
        max-height: 65px !important;
        max-width: 220px !important;
    }
    
    .company-selector-wrapper-brand {
        margin-top: 0;
    }
    
    .company-selector-brand {
        font-size: 0.7rem;
        padding: 0.35rem 0.5rem;
        max-width: 140px;
    }
    
    .current-company-badge-brand {
        margin-top: 0;
        font-size: 0.7rem;
        padding: 0.35rem 0.5rem;
    }
}

.company-selector-brand:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.6);
}

.company-selector-brand:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.35);
    border-color: white;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.2);
}

.company-selector-brand option {
    background: var(--primary-color);
    color: white;
}

.current-company-badge-brand {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.4);
    color: white;
    padding: 0.4rem 0.65rem;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 500;
    display: inline-block;
    margin-top: 0.5rem;
    max-width: 180px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ==========================================================================
   MAIN CONTENT - MOBILE FIRST
   ========================================================================== */

.main-content {
    padding: 1rem;
    min-height: calc(100vh - 200px);
}

.page-header {
    margin-bottom: 1.5rem;
}

.page-header h1 {
    font-size: 1.75rem;
    margin-bottom: 0.5rem;
    line-height: 1.2;
}

.subtitle {
    color: var(--secondary-color);
    font-size: 1rem;
}

/* ==========================================================================
   CARDS - MOBILE FIRST
   ========================================================================== */

.card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 1.25rem;
    box-shadow: var(--shadow);
    margin-bottom: 1.25rem;
}

.card h3 {
    margin-bottom: 1rem;
    color: var(--primary-color);
    font-size: 1.25rem;
}

/* Dashboard Grid - Mobile */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.25rem;
}

.card-full {
    grid-column: 1;
}

/* KPI Grid - Mobile */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.kpi-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 1rem;
    text-align: center;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--primary-color);
}

.kpi-value {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary-color);
    margin-bottom: 0.25rem;
}

.kpi-label {
    color: var(--secondary-color);
    font-size: 0.75rem;
    line-height: 1.2;
}

/* ==========================================================================
   TABLES - MOBILE FIRST
   ========================================================================== */

.table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -1.25rem;
    padding: 0 1.25rem;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
    font-size: 0.9rem;
}

th {
    background-color: var(--bg-color);
    padding: 0.75rem 0.5rem;
    text-align: left;
    font-weight: 600;
    color: var(--secondary-color);
    border-bottom: 2px solid var(--border-color);
    font-size: 0.85rem;
    white-space: nowrap;
}

td {
    padding: 0.75rem 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

tr:hover {
    background-color: var(--bg-color);
}

.row-new {
    background-color: #f0fff4 !important;
    border-left: 4px solid var(--success-color);
}

.row-cancel {
    background-color: #fff5f5 !important;
    border-left: 4px solid var(--danger-color);
}

.row-move {
    background-color: #ebf8ff !important;
    border-left: 4px solid var(--info-color);
}

.row-keep {
    background-color: #fafafa !important;
}

/* Status Badges */
.status-badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.status-new {
    background-color: var(--success-color);
    color: white;
}

.status-cancel {
    background-color: var(--danger-color);
    color: white;
}

.status-move {
    background-color: var(--info-color);
    color: white;
}

.status-keep {
    background-color: var(--secondary-color);
    color: white;
}

/* ==========================================================================
   BUTTONS - MOBILE FIRST
   ========================================================================== */

.btn {
    display: inline-block;
    padding: 0.875rem 1.25rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.3s;
    text-align: center;
    width: 100%;
    -webkit-tap-highlight-color: transparent;
}

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

.btn-primary:hover {
    background-color: #2c5282;
    box-shadow: var(--shadow-lg);
}

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

.btn-secondary:hover {
    background-color: #2d3748;
}

.btn-sm {
    padding: 0.625rem 1rem;
    font-size: 0.875rem;
}

/* ==========================================================================
   FORMS - MOBILE FIRST
   ========================================================================== */

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-color);
    font-size: 0.95rem;
}

.form-group input:not([type="checkbox"]):not([type="radio"]),
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.875rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s;
    -webkit-appearance: none;
}

.form-group input[type="checkbox"],
.form-group input[type="radio"] {
    width: auto;
    cursor: pointer;
}

.form-group input:not([type="checkbox"]):not([type="radio"]):focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

.form-group small {
    display: block;
    margin-top: 0.25rem;
    color: var(--secondary-color);
    font-size: 0.85rem;
}

/* Search & Filters - Mobile */
.search-box input,
.filters input,
.filters select {
    padding: 0.875rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    margin-bottom: 1rem;
    width: 100%;
}

.filters {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.btn-export {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 0.875rem 1.5rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-export:hover {
    background: #2c5282;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(49, 130, 206, 0.3);
}

/* ==========================================================================
   MODALS - MOBILE FIRST
   ========================================================================== */

.modal {
    display: none;
    position: fixed;
    z-index: 10100;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
}

.modal[style*="display: block"],
.modal[style*="display: flex"] {
    display: flex !important;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.modal-dispositivo {
    padding: 0;
}

.modal-header-simple {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem;
    border-bottom: 1px solid #e5e7eb;
}

.modal-header-simple h2 {
    margin: 0;
    font-size: 1.25rem;
    color: #1f2937;
}

.modal-body-simple {
    padding: 1.25rem;
}

.modal-header {
    padding: 1.25rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    background: white;
    z-index: 1;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.25rem;
}

.close {
    font-size: 2rem;
    font-weight: bold;
    cursor: pointer;
    color: var(--secondary-color);
    line-height: 1;
    padding: 0.5rem;
}

.close:hover {
    color: var(--text-color);
}

.modal-body {
    padding: 1.25rem;
}

/* ==========================================================================
   MAP - MOBILE FIRST
   ========================================================================== */

#map {
    height: 300px;
    border-radius: 12px;
    margin-bottom: 1rem;
}

/* ==========================================================================
   CHARTS - MOBILE FIRST
   ========================================================================== */

.chart-container {
    position: relative;
    height: 250px;
    margin-bottom: 1rem;
}

/* ==========================================================================
   FLASH MESSAGES - MOBILE FIRST
   ========================================================================== */

.flash-messages {
    position: fixed;
    top: 80px;
    left: 1rem;
    right: 1rem;
    z-index: 1000;
}

.flash-message {
    padding: 1rem;
    margin-bottom: 0.5rem;
    border-radius: 8px;
    font-weight: 500;
    animation: slideDown 0.3s ease;
}

.flash-success {
    background-color: #c6f6d5;
    color: #22543d;
    border-left: 4px solid var(--success-color);
}

.flash-error {
    background-color: #fed7d7;
    color: #742a2a;
    border-left: 4px solid var(--danger-color);
}

.flash-info {
    background-color: #bee3f8;
    color: #2c5282;
    border-left: 4px solid var(--info-color);
}

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

/* ==========================================================================
   UTILITIES - MOBILE FIRST
   ========================================================================== */

.loading {
    text-align: center;
    padding: 2rem;
    color: var(--secondary-color);
}

.spinner {
    border: 3px solid var(--border-color);
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.text-center {
    text-align: center;
}

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }

/* ==========================================================================
   TABLET BREAKPOINT (768px+)
   ========================================================================== */

@media (min-width: 768px) {
    /* Hide burger menu */
    .burger-menu {
        display: none;
    }

    /* Horizontal nav menu */
    .nav-menu {
        position: static;
        width: auto;
        height: auto;
        flex-direction: row;
        padding-top: 0;
        box-shadow: none;
        flex: 1;
        justify-content: space-between;
        margin: 0 0.5rem;
    }

    .nav-links {
        flex-direction: row;
        gap: 0;
        padding: 0;
        order: 0;
    }

    .nav-link {
        padding: 0.4rem 0.2rem;
        border-radius: 4px;
        font-size: 0.65rem;
        white-space: nowrap;
        letter-spacing: -0.4px;
    }
    
    .nav-icon-only {
        padding: 0.4rem 0.4rem;
        font-size: 0.95rem;
    }
    
    .nav-text-short {
        display: inline;
    }
    
    .nav-text-full {
        display: none;
    }
    
    .nav-link:hover,
    .nav-link.active {
        transform: none;
    }
    
    .nav-brand-link {
        flex-direction: column;
        gap: 4px;
    }

    .nav-user,
    .nav-user-top {
        flex-direction: row;
        align-items: center;
        gap: 0.5rem;
        border: none;
        padding: 0.5rem 0.75rem;
        background: rgba(0, 0, 0, 0.25);
        border-radius: 8px;
        margin-left: auto;
        margin-bottom: 0;
        order: 1;
    }
    
    .nav-user-top .nav-link {
        background: transparent;
        border: none;
        border-left: none;
        font-weight: 400;
    }
    
    /* Desktop: nascondi il testo, mostra solo icone */
    .nav-user-top .nav-text-user {
        display: none;
    }
    
    .nav-user-top .nav-icon {
        font-size: 1.1rem;
    }

    .nav-profile {
        padding: 0.5rem 0.65rem;
    }

    /* Main content */
    .main-content {
        padding: 2rem;
    }

    .page-header h1 {
        font-size: 2rem;
    }

    /* Cards */
    .dashboard-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .card-full {
        grid-column: 1 / -1;
    }

    .kpi-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 1rem;
    }

    .kpi-card {
        padding: 1.5rem;
    }

    .kpi-value {
        font-size: 2rem;
    }

    .kpi-label {
        font-size: 0.9rem;
    }

    /* Tables */
    table {
        font-size: 1rem;
    }

    th, td {
        padding: 0.75rem;
    }

    /* Buttons */
    .btn {
        width: auto;
    }

    /* Filters */
    .filters {
        flex-direction: row;
        gap: 1rem;
    }

    /* Modals */
    .modal {
        align-items: center;
    }

    .modal-content {
        border-radius: 12px;
        width: 90%;
        max-width: 600px;
    }
    
    .modal-dispositivo {
        max-width: 500px;
    }
    
    .modal-header-simple {
        padding: 1.5rem 2rem;
    }
    
    .modal-header-simple h2 {
        font-size: 1.5rem;
    }
    
    .modal-body-simple {
        padding: 1.5rem 2rem 2rem;
    }

    /* Map & Charts */
    #map {
        height: 400px;
    }

    .chart-container {
        height: 300px;
    }
}

/* ==========================================================================
   DESKTOP BREAKPOINT (1024px+)
   ========================================================================== */

@media (min-width: 1024px) {
    .nav-container {
        max-width: 1400px;
        margin: 0 auto;
        padding: 1rem 2rem;
    }

    .nav-link {
        padding: 0.5rem 1rem;
        font-size: 1rem;
    }

    .main-content {
        max-width: 1400px;
        margin: 2rem auto;
        padding: 0 2rem;
    }

    .page-header h1 {
        font-size: 2.5rem;
    }

    .subtitle {
        font-size: 1.1rem;
    }

    .dashboard-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 1.5rem;
    }

    .kpi-grid {
        grid-template-columns: repeat(6, 1fr);
    }

    .card {
        padding: 1.5rem;
    }

    .card:hover {
        transform: translateY(-2px);
        box-shadow: var(--shadow-lg);
    }

    #map {
        height: 500px;
    }

    .chart-container {
        height: 350px;
    }
}

/* ==========================================================================
   LARGE DESKTOP BREAKPOINT (1440px+)
   ========================================================================== */

@media (min-width: 1280px) {
    .nav-text-short {
        display: none;
    }
    
    .nav-text-full {
        display: inline;
    }
    
    .nav-link {
        padding: 0.5rem 0.75rem;
    }
}

@media (min-width: 1440px) {
    .nav-links {
        gap: 0.5rem;
    }
    
    .nav-link {
        padding: 0.5rem 1rem;
    }

    .kpi-value {
        font-size: 2.5rem;
    }

    .page-header h1 {
        font-size: 3rem;
    }
}

/* ==========================================================================
   MOBILE OPTIMIZATIONS
   ========================================================================== */

/* Tabelle responsive */
.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -1rem;
    padding: 0 1rem;
}

@media (max-width: 767px) {
    /* Contenitore principale */
    .main-content {
        padding: 0.75rem;
    }
    
    .container {
        padding: 0;
    }
    
    /* Tabelle responsive */
    .table-wrapper {
        margin: 0 -0.75rem;
        padding: 0 0.75rem;
    }
    
    .table-container {
        margin: 0 -0.75rem;
        padding: 0 0.75rem;
    }
    
    table {
        min-width: 600px;
        font-size: 0.875rem;
    }
    
    table th,
    table td {
        padding: 0.5rem !important;
        white-space: nowrap;
    }
    
    /* Card compatte su mobile */
    .card {
        padding: 1rem;
        margin-bottom: 1rem;
    }
    
    .kpi-card {
        padding: 0.875rem;
    }
    
    .kpi-value {
        font-size: 1.5rem;
    }
    
    .kpi-label {
        font-size: 0.75rem;
    }
    
    /* Form ottimizzati */
    .form-group {
        margin-bottom: 1rem;
    }
    
    .form-control,
    .btn,
    input,
    select,
    textarea {
        font-size: 16px !important; /* Previene zoom su iOS */
    }
    
    /* Buttons più compatti */
    .btn {
        padding: 0.75rem 1rem;
    }
    
    .btn-sm {
        padding: 0.5rem 0.75rem;
        font-size: 0.8125rem;
    }
    
    /* Sezioni più compatte */
    .section-header {
        margin-bottom: 1rem;
    }
    
    .section-header h2 {
        font-size: 1.25rem;
    }
    
    .page-header {
        margin-bottom: 1rem;
    }
    
    .page-header h1 {
        font-size: 1.5rem;
    }
    
    /* Modal mobile-friendly */
    .modal-content {
        margin: 0.5rem;
        max-height: calc(100vh - 1rem);
        overflow-y: auto;
        width: calc(100% - 1rem);
    }
    
    .modal-header h3 {
        font-size: 1.25rem;
    }
    
    /* File manager mobile */
    .file-manager-container {
        flex-direction: column;
    }
    
    .folders-tree {
        width: 100%;
        max-height: 200px;
        margin-bottom: 1rem;
        overflow-y: auto;
    }
    
    .files-list {
        width: 100%;
    }
    
    /* Dashboard grid su mobile */
    .dashboard-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    
    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }
    
    /* Filters mobile */
    .filters {
        gap: 0.5rem;
        margin-bottom: 0.75rem;
    }
    
    .search-box {
        margin-bottom: 0.75rem;
    }
    
    /* Action buttons */
    .btn-group {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .btn-group .btn {
        width: 100%;
    }
    
    /* Nascondi testo lungo */
    .nav-text-full {
        display: none;
    }
    
    .nav-text-short {
        display: inline;
    }
    
    /* Ottimizzazione spazi */
    .section-content {
        padding: 0.75rem;
    }
    
    /* Stats cards compatti */
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    
    /* Badge più piccoli */
    .badge {
        font-size: 0.75rem;
        padding: 0.25rem 0.5rem;
    }
}

/* ==========================================================================
   ACCESSIBILITY & TOUCH IMPROVEMENTS
   ========================================================================== */

@media (hover: none) and (pointer: coarse) {
    /* Touch devices - larger tap targets */
    .btn {
        min-height: 44px;
    }

    .nav-link {
        min-height: 44px;
    }

    a, button, input, select {
        min-height: 44px;
    }
}

/* Focus states */
*:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Print styles */
@media print {
    .navbar,
    .burger-menu,
    .btn,
    footer {
        display: none;
    }

    .main-content {
        max-width: 100%;
        padding: 0;
    }
}

/* ==========================================================================
   LEAFLET MAP POPUP OVERRIDES
   ========================================================================== */

/* Override global table white-space for map popups */
.leaflet-popup.sede-popup .leaflet-popup-content {
    margin: 0 !important;
    padding: 8px !important;
}

.leaflet-popup.sede-popup .leaflet-popup-content-wrapper {
    padding: 0 !important;
}

.leaflet-popup.sede-popup td,
.leaflet-popup.sede-popup th {
    white-space: normal !important;
    overflow-wrap: break-word !important;
    word-wrap: break-word !important;
}

.leaflet-popup.sede-popup table {
    table-layout: fixed !important;
}

/* ==========================================================================
   MEMBER DETAILS BUTTON
   ========================================================================== */

.btn-details:hover {
    background: #2c5282 !important;
}

/* ==========================================================================
   DELETE SNAPSHOT BUTTON
   ========================================================================== */

.btn-delete-snapshot {
    background: transparent;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.btn-delete-snapshot:hover {
    background: #fed7d7;
    transform: scale(1.1);
}
