/* ========================================
   Essepi Ortofrutta - Tema Moderno & Fresco
   Palette: Verde (#2d6a4f) + Arancione (#e76f51) + Bianco
   ======================================== */

:root {
    --primary: #2d6a4f;
    --primary-light: #40916c;
    --primary-dark: #1b4332;
    --accent: #e76f51;
    --accent-light: #f4a261;
    --accent-dark: #d62828;
    --bg-light: #f0f4f0;
    --bg-card: #ffffff;
    --text-dark: #1a1a2e;
    --text-muted: #6c757d;
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* === BASE === */
body {
    background: var(--bg-light);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    color: var(--text-dark);
    min-height: 100vh;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: var(--transition);
}
a:hover {
    color: var(--primary-dark);
}

/* === NAVBAR === */
.navbar-custom {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
    box-shadow: var(--shadow-md);
    padding: 0.6rem 1rem;
}
.navbar-custom .navbar-brand {
    font-weight: 700;
    font-size: 1.25rem;
    color: #fff !important;
    letter-spacing: -0.5px;
}
.navbar-custom .navbar-brand .brand-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: var(--accent);
    border-radius: 10px;
    margin-right: 10px;
    font-size: 1.1rem;
}
.navbar-custom .nav-link {
    color: rgba(255,255,255,0.8) !important;
    font-weight: 500;
    padding: 0.5rem 1rem !important;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}
.navbar-custom .nav-link:hover,
.navbar-custom .nav-link.active {
    color: #fff !important;
    background: rgba(255,255,255,0.15);
}
.navbar-custom .dropdown-menu {
    border: none;
    box-shadow: var(--shadow-lg);
    border-radius: var(--radius-md);
    padding: 0.5rem;
}
.navbar-custom .dropdown-item {
    border-radius: var(--radius-sm);
    padding: 0.5rem 1rem;
    transition: var(--transition);
}
.navbar-custom .dropdown-item:hover {
    background: var(--bg-light);
    color: var(--primary);
}

/* Search bar in navbar */
.navbar-search {
    position: relative;
    max-width: 300px;
    flex: 1;
}
.navbar-search .form-control {
    border-radius: 20px;
    padding-left: 2.5rem;
    padding-right: 1rem;
    border: 2px solid rgba(255,255,255,0.2);
    background: rgba(255,255,255,0.15);
    color: #fff;
    font-size: 0.9rem;
    width: 100%;
}
.navbar-search .form-control::placeholder {
    color: rgba(255,255,255,0.6);
}
.navbar-search .form-control:focus {
    background: rgba(255,255,255,0.25);
    border-color: var(--accent-light);
    box-shadow: none;
    color: #fff;
}
.navbar-search .search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: rgba(255,255,255,0.6);
    font-size: 0.9rem;
    z-index: 2;
}
.navbar-search .search-results {
    position: absolute;
    top: 100%;
    right: 0;
    width: 360px;
    max-width: 90vw;
    background: #fff;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    max-height: 400px;
    overflow-y: auto;
    z-index: 999;
    display: none;
    margin-top: 4px;
}
.navbar-search .search-results.active {
    display: block;
}
.navbar-search .search-result-item {
    padding: 12px 16px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-dark);
    display: block;
    text-decoration: none;
}
.navbar-search .search-result-item:last-child {
    border-bottom: none;
}
.navbar-search .search-result-item:hover,
.navbar-search .search-result-item:active {
    background: var(--bg-light);
}
.navbar-search .search-result-item .result-type {
    font-size: 0.72rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}
.navbar-search .search-result-item .result-title {
    font-weight: 600;
    margin-top: 2px;
    font-size: 0.95rem;
}
.navbar-search .search-no-results {
    padding: 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Notification badge */
.notification-wrapper {
    position: relative;
}
.notification-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 18px;
    height: 18px;
    background: var(--accent);
    color: #fff;
    border-radius: 50%;
    font-size: 0.65rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--primary);
    animation: pulse 2s infinite;
}
@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* Notification dropdown */
.notification-dropdown {
    width: 360px;
    max-height: 480px;
    overflow-y: auto;
    padding: 0;
}
.notification-dropdown .notification-header {
    padding: 12px 16px;
    font-weight: 700;
    border-bottom: 1px solid #f0f0f0;
    color: var(--text-dark);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.notification-dropdown .notification-item {
    padding: 12px 16px;
    border-bottom: 1px solid #f8f8f8;
    transition: var(--transition);
    cursor: pointer;
}
.notification-dropdown .notification-item:hover {
    background: var(--bg-light);
}
.notification-dropdown .notification-item.unread {
    background: #f0faf4;
    border-left: 3px solid var(--primary);
}
.notification-dropdown .notification-item .notif-time {
    font-size: 0.75rem;
    color: var(--text-muted);
}
.notification-dropdown .notification-item .notif-text {
    font-size: 0.9rem;
    margin-top: 2px;
}
.notification-empty {
    padding: 24px;
    text-align: center;
    color: var(--text-muted);
}

/* === CARDS === */
.card {
    border: none;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    background: var(--bg-card);
}
.card:hover {
    box-shadow: var(--shadow-md);
}
.card-header {
    background: transparent;
    border-bottom: 1px solid #f0f0f0;
    font-weight: 600;
    padding: 1rem 1.25rem;
}
.card-header i {
    margin-right: 8px;
    color: var(--primary);
}

/* KPI Cards */
.kpi-card {
    border-radius: var(--radius-md);
    padding: 1.5rem;
    color: #fff;
    position: relative;
    overflow: hidden;
    transition: var(--transition);
    border: none;
}
.kpi-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}
.kpi-card .kpi-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-md);
    background: rgba(255,255,255,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin-bottom: 1rem;
}
.kpi-card .kpi-value {
    font-size: 2rem;
    font-weight: 800;
    line-height: 1;
    margin-bottom: 0.25rem;
}
.kpi-card .kpi-label {
    font-size: 0.85rem;
    opacity: 0.9;
    font-weight: 500;
}
.kpi-card::after {
    content: '';
    position: absolute;
    top: -50%;
    right: -30%;
    width: 200px;
    height: 200px;
    background: rgba(255,255,255,0.08);
    border-radius: 50%;
}
.kpi-card.bg-kpi-green {
    background: linear-gradient(135deg, #2d6a4f 0%, #40916c 100%);
}
.kpi-card.bg-kpi-orange {
    background: linear-gradient(135deg, #e76f51 0%, #f4a261 100%);
}
.kpi-card.bg-kpi-blue {
    background: linear-gradient(135deg, #1a759f 0%, #34a0a4 100%);
}
.kpi-card.bg-kpi-purple {
    background: linear-gradient(135deg, #7b2cbf 0%, #9d4edd 100%);
}
.kpi-card.bg-kpi-teal {
    background: linear-gradient(135deg, #0077b6 0%, #00b4d8 100%);
}

/* === BUTTONS === */
.btn {
    border-radius: var(--radius-sm);
    font-weight: 600;
    padding: 0.5rem 1.25rem;
    transition: var(--transition);
    border: none;
}
.btn:hover {
    transform: translateY(-1px);
}
.btn-primary {
    background: var(--primary);
    color: #fff;
}
.btn-primary:hover {
    background: var(--primary-dark);
    box-shadow: 0 4px 12px rgba(45,106,79,0.3);
}
.btn-accent {
    background: var(--accent);
    color: #fff;
}
.btn-accent:hover {
    background: var(--accent-dark);
    box-shadow: 0 4px 12px rgba(231,111,81,0.3);
}
.btn-success {
    background: #2d6a4f;
}
.btn-outline-primary {
    border-color: var(--primary);
    color: var(--primary);
}
.btn-outline-primary:hover {
    background: var(--primary);
    color: #fff;
}
.btn-outline-secondary {
    border-color: #dee2e6;
    color: var(--text-muted);
}
.btn-outline-secondary:hover {
    background: #f8f9fa;
    color: var(--text-dark);
}

/* === BADGES === */
.badge-stato {
    padding: 0.4em 0.8em;
    font-weight: 600;
    font-size: 0.78rem;
    border-radius: 6px;
    letter-spacing: 0.3px;
}
.badge-creato {
    background: #fff3cd;
    color: #856404;
}
.badge-in_preparazione {
    background: #fde2d4;
    color: #c1121f;
}
.badge-in_carico {
    background: #d0e1f9;
    color: #1a759f;
}
.badge-consegnato {
    background: #d4edda;
    color: #155724;
}
.badge-archiviato {
    background: #e2e3e5;
    color: #383d41;
}
.badge-non_consegnato {
    background: #f8d7da;
    color: #842029;
}

.badge-pagamento {
    padding: 0.35em 0.7em;
    font-weight: 600;
    font-size: 0.75rem;
    border-radius: 6px;
}
.badge-incassato {
    background: #d4edda;
    color: #155724;
}
.badge-in_sospeso {
    background: #fff3cd;
    color: #856404;
}
.badge-ddt {
    background: #d0e1f9;
    color: #1a759f;
}

/* === TABLES === */
.table {
    border-collapse: separate;
    border-spacing: 0;
}
.table thead th {
    background: var(--bg-light);
    border-bottom: 2px solid #dee2e6;
    font-weight: 700;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    padding: 0.75rem 1rem;
}
.table tbody td {
    padding: 0.85rem 1rem;
    vertical-align: middle;
    border-bottom: 1px solid #f0f0f0;
}
.table tbody tr {
    transition: var(--transition);
}
.table tbody tr:hover {
    background: #f8faf8;
}

/* === FORMS === */
.form-control, .form-select {
    border-radius: var(--radius-sm);
    border: 2px solid #e9ecef;
    padding: 0.6rem 1rem;
    transition: var(--transition);
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(45,106,79,0.15);
}
.form-floating > .form-control:focus ~ label,
.form-floating > .form-select:focus ~ label {
    color: var(--primary);
}
.form-label {
    font-weight: 600;
    font-size: 0.88rem;
    color: var(--text-dark);
    margin-bottom: 0.4rem;
}

/* === LOGIN PAGE === */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 50%, var(--primary-light) 100%);
    position: relative;
    overflow: hidden;
}
.login-wrapper::before {
    content: '';
    position: absolute;
    width: 500px;
    height: 500px;
    background: rgba(231,111,81,0.15);
    border-radius: 50%;
    top: -100px;
    right: -100px;
}
.login-wrapper::after {
    content: '';
    position: absolute;
    width: 400px;
    height: 400px;
    background: rgba(255,255,255,0.05);
    border-radius: 50%;
    bottom: -150px;
    left: -100px;
}
.login-card {
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(20px);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
    position: relative;
    z-index: 1;
}
.login-card .login-logo {
    width: 72px;
    height: 72px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
    font-size: 2rem;
    color: #fff;
    box-shadow: 0 8px 24px rgba(45,106,79,0.3);
}
.login-card h2 {
    text-align: center;
    font-weight: 800;
    color: var(--text-dark);
    margin-bottom: 0.5rem;
}
.login-card .login-subtitle {
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 2rem;
    font-size: 0.9rem;
}
.login-card .btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    border: none;
    padding: 0.75rem;
    font-size: 1rem;
    font-weight: 700;
    border-radius: var(--radius-sm);
}
.login-card .btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
    box-shadow: 0 6px 20px rgba(45,106,79,0.35);
    transform: translateY(-2px);
}

/* === PAGE HEADERS === */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #f0f0f0;
}
.page-header h1 {
    font-weight: 800;
    font-size: 1.75rem;
    color: var(--text-dark);
    margin: 0;
}
.page-header h1 i {
    color: var(--primary);
    margin-right: 10px;
}

/* === ALERTS === */
.alert {
    border: none;
    border-radius: var(--radius-md);
    font-weight: 500;
    padding: 0.85rem 1.25rem;
}
.alert-success {
    background: #d4edda;
    color: #155724;
    border-left: 4px solid #28a745;
}
.alert-danger {
    background: #f8d7da;
    color: #721c24;
    border-left: 4px solid #dc3545;
}
.alert-warning {
    background: #fff3cd;
    color: #856404;
    border-left: 4px solid #ffc107;
}
.alert-info {
    background: #d0e1f9;
    color: #0c5460;
    border-left: 4px solid #17a2b8;
}

/* === ACCORDION === */
.accordion-item {
    border: none;
    border-radius: var(--radius-md) !important;
    margin-bottom: 0.5rem;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}
.accordion-button {
    border-radius: var(--radius-md) !important;
    font-weight: 600;
    padding: 1rem 1.25rem;
}
.accordion-button:not(.collapsed) {
    background: #f0faf4;
    color: var(--primary);
}
.accordion-button::after {
    filter: none;
}

/* === QUICK ACTIONS === */
.quick-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
}
.quick-action-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    text-align: center;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    cursor: pointer;
    text-decoration: none;
    color: var(--text-dark);
    border: 2px solid transparent;
}
.quick-action-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary-light);
    color: var(--text-dark);
}
.quick-action-card .qa-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 0.75rem;
    font-size: 1.25rem;
}
.quick-action-card .qa-icon.green { background: #d4edda; color: #2d6a4f; }
.quick-action-card .qa-icon.orange { background: #fde2d4; color: #e76f51; }
.quick-action-card .qa-icon.blue { background: #d0e1f9; color: #1a759f; }
.quick-action-card .qa-icon.purple { background: #e8d4f8; color: #7b2cbf; }
.quick-action-card .qa-label {
    font-weight: 600;
    font-size: 0.9rem;
}

/* === RECENT ORDERS LIST === */
.recent-order-item {
    display: flex;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid #f0f0f0;
    transition: var(--transition);
}
.recent-order-item:last-child {
    border-bottom: none;
}
.recent-order-item:hover {
    background: #fafafa;
    margin: 0 -1.25rem;
    padding-left: 1.25rem;
    padding-right: 1.25rem;
}
.recent-order-item .order-id {
    width: 48px;
    height: 48px;
    background: var(--bg-light);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: var(--primary);
    margin-right: 12px;
    flex-shrink: 0;
}
.recent-order-item .order-info {
    flex: 1;
    min-width: 0;
}
.recent-order-item .order-info .order-client {
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.recent-order-item .order-info .order-date {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* === DRIVER CARDS === */
.driver-order-card {
    border-radius: var(--radius-md);
    border-left: 4px solid var(--primary);
    transition: var(--transition);
}
.driver-order-card:hover {
    box-shadow: var(--shadow-md);
}
.driver-order-card.status-creato {
    border-left-color: #ffc107;
}
.driver-order-card.status-in_preparazione {
    border-left-color: #e76f51;
}
.driver-order-card.status-in_carico {
    border-left-color: #1a759f;
}
.driver-order-card.status-consegnato {
    border-left-color: #2d6a4f;
}

/* === SECTION DIVIDERS === */
.section-divider {
    display: flex;
    align-items: center;
    margin: 1.5rem 0 1rem;
    color: var(--text-muted);
    font-weight: 700;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}
.section-divider::after {
    content: '';
    flex: 1;
    height: 2px;
    background: linear-gradient(to right, #dee2e6, transparent);
    margin-left: 12px;
}
.section-divider i {
    margin-right: 8px;
    color: var(--primary);
}

/* === SCROLLBAR === */
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: #aaa;
}

/* === ANIMATIONS === */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
.animate-in {
    animation: fadeInUp 0.4s ease-out;
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .kpi-card {
        padding: 0.6rem;
    }
    .kpi-card .kpi-icon {
        width: 32px;
        height: 32px;
        font-size: 0.9rem;
        margin-bottom: 0.3rem;
    }
    .kpi-card .kpi-value {
        font-size: 1.2rem;
    }
    .kpi-card .kpi-label {
        font-size: 0.7rem;
    }
    .kpi-card:hover {
        transform: none;
    }
    .page-header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }
    .page-header h1 {
        font-size: 1.4rem;
    }
    .notification-dropdown {
        width: 300px;
    }
    .quick-actions {
        grid-template-columns: repeat(2, 1fr);
    }
    .navbar-search {
        max-width: 180px;
    }
    .navbar-search .search-results {
        position: fixed;
        left: 12px;
        right: 12px;
        top: 60px;
        width: auto;
        max-width: none;
    }
}

@media (max-width: 576px) {
    .login-card {
        margin: 1rem;
        padding: 1.5rem;
    }
    .quick-actions {
        grid-template-columns: 1fr 1fr;
    }
}

/* === EMPTY STATES === */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}
.empty-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.4;
}
.empty-state p {
    font-size: 1rem;
    max-width: 400px;
    margin: 0 auto;
}

/* === LOADING LIST SPECIFIC === */
.loading-list-print {
    background: #fff;
    padding: 2rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}
@media print {
    .no-print, .navbar-custom, .btn { display: none !important; }
    .loading-list-print { box-shadow: none; padding: 0; }
    body { background: #fff; }
}

/* === MISC === */
.shadow-custom { box-shadow: var(--shadow-sm); }
.shadow-custom-md { box-shadow: var(--shadow-md); }
.rounded-custom { border-radius: var(--radius-md); }
.text-primary-custom { color: var(--primary) !important; }
.text-accent-custom { color: var(--accent) !important; }
.bg-light-custom { background: var(--bg-light) !important; }

/* === SCANNER === */
#reader {
    border-radius: var(--radius-md);
    overflow: hidden;
}
#reader video {
    border-radius: var(--radius-md);
}
#reader__scan_region {
    min-height: 280px;
}
#reader__dashboard {
    display: none !important;
}

/* === DRIVER PORTFOLIO === */
.portfolio-order-card {
    border-left: 4px solid var(--primary);
    transition: var(--transition);
}
.portfolio-order-card:hover {
    transform: translateX(4px);
    box-shadow: var(--shadow-md);
}
.portfolio-order-card.card-delivered {
    border-left-color: #28a745;
    opacity: 0.75;
}

/* === STATISTICS CHARTS === */
.progress {
    border-radius: 8px;
    background: #f0f0f0;
}
.progress-bar {
    border-radius: 8px;
    transition: width 0.6s ease;
}

/* === RESPONSIVE SCANNER === */
@media (max-width: 576px) {
    .scanner-wrapper {
        padding: 0.5rem;
    }
    .scanner-overlay {
        width: 180px;
        height: 180px;
    }
}

/* === MOBILE TOUCH OPTIMIZATIONS === */
@media (max-width: 768px) {
    /* Bigger touch targets: minimum 48px */
    .btn {
        min-height: 44px;
    }
    .btn-sm {
        min-height: 36px;
    }
    .btn-close {
        width: 28px;
        height: 28px;
        padding: 4px;
    }

    /* Cards spacing */
    .card {
        border-radius: 14px !important;
    }
    .card-body {
        padding: 1rem;
    }

    /* Driver order cards: thicker status border */
    .driver-order-card.status-creato { border-left: 5px solid #6c757d; }
    .driver-order-card.status-in_preparazione { border-left: 5px solid var(--accent); }
    .driver-order-card.status-in_carico { border-left: 5px solid var(--primary); }
    .driver-order-card.status-consegnato { border-left: 5px solid #28a745; }

    /* Bigger form inputs for mobile */
    .form-control {
        font-size: 1rem;
        padding: 0.65rem 0.75rem;
    }
    .form-select {
        font-size: 1rem;
        padding: 0.65rem 0.75rem;
    }

    /* Modal: full width on mobile */
    .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100vw - 1rem);
    }
    .modal-content {
        border-radius: 16px !important;
    }

    /* Page header */
    .page-header {
        margin-bottom: 1rem;
    }
    .page-header h1 {
        font-size: 1.3rem;
    }

    /* Navbar search results: full width */
    .search-results-dropdown {
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        max-height: 50vh;
    }

    /* KPI cards: compact */
    .kpi-card {
        padding: 0.75rem;
    }
    .kpi-card-value {
        font-size: 1.4rem;
    }

    /* Table responsiveness */
    .table {
        font-size: 0.85rem;
    }
    .table th {
        font-size: 0.75rem;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        padding: 0.5rem 0.4rem;
    }
    .table td {
        padding: 0.5rem 0.4rem;
        vertical-align: middle;
    }

    /* Badge states: bigger */
    .badge-stato {
        font-size: 0.7rem;
        padding: 0.3rem 0.6rem;
    }

    /* Accordion: bigger toggle */
    .accordion-button {
        padding: 0.75rem;
        font-size: 0.95rem;
    }

    /* Pull-to-refresh hint */
    body {
        overscroll-behavior-y: contain;
    }

    /* Smooth scroll */
    html {
        scroll-behavior: smooth;
        -webkit-overflow-scrolling: touch;
    }

    /* Disable text selection on buttons for faster tapping */
    .btn, .badge-stato, .accordion-button {
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        user-select: none;
    }

    /* Focus visible for accessibility */
    .btn:focus-visible, .form-control:focus-visible {
        outline: 3px solid var(--primary);
        outline-offset: 2px;
    }

    /* Quick action: swipe hint */
    .driver-order-card {
        position: relative;
        overflow: hidden;
    }

    /* Loading spinner */
    .btn-loading {
        position: relative;
        pointer-events: none;
        opacity: 0.7;
    }
    .btn-loading::after {
        content: '';
        width: 16px;
        height: 16px;
        border: 2px solid transparent;
        border-top-color: #fff;
        border-radius: 50%;
        animation: spin 0.6s linear infinite;
        display: inline-block;
        margin-left: 8px;
        vertical-align: middle;
    }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* === MOBILE SAFE AREAS (iPhone notch) === */
@supports (padding-top: env(safe-area-inset-top)) {
    .navbar-custom {
        padding-top: env(safe-area-inset-top);
    }
    body {
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* === PWA-READY: prevent zoom on input focus === */
@media (max-width: 768px) {
    input[type="text"],
    input[type="number"],
    input[type="email"],
    input[type="password"],
    textarea,
    select {
        font-size: 16px !important;
    }
}

/* === FLOATING ACTION BUTTON (Scan) === */
.fab-scan {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent) 0%, #d4533a 100%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    text-decoration: none;
    box-shadow: 0 6px 20px rgba(231,111,81,0.5);
    z-index: 1040;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
}
.fab-scan:active {
    transform: scale(0.92);
    box-shadow: 0 3px 10px rgba(231,111,81,0.4);
}
@media (min-width: 769px) {
    .fab-scan {
        display: none !important;
    }
}

/* === FLOATING ACTION BUTTON (Nuovo Ordine) === */
.fab-new-order {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    text-decoration: none;
    box-shadow: 0 6px 20px rgba(45,106,79,0.5);
    z-index: 1040;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
}
.fab-new-order:active {
    transform: scale(0.92);
    box-shadow: 0 3px 10px rgba(45,106,79,0.4);
}
@media (min-width: 769px) {
    .fab-new-order {
        display: none !important;
    }
}
