/* Business Control - Standalone Website Styles */
.dashboard-compact .card {
    border-radius: 10px;
}
.dashboard-compact .card-body { padding: 1rem; }
.dashboard-compact h1, .dashboard-compact h2, .dashboard-compact h5 { margin-bottom: 0.5rem; }
.dashboard-compact .btn { padding: 0.4rem 0.75rem; font-size: 0.9rem; }
.dashboard-compact .quick-card .btn { width: 160px; max-width: 100%; }
.dashboard-compact .quick-card .card-body { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.dashboard-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 12px; }
.dashboard-grid .grid-col-3 { grid-column: span 3; }
.dashboard-grid .grid-col-4 { grid-column: span 4; }
.dashboard-grid .grid-col-6 { grid-column: span 6; }
.dashboard-grid .grid-col-12 { grid-column: span 12; }
.stat-card { display:flex; align-items:center; justify-content:space-between; border-radius:10px; }
.stat-card .h4 { font-size: 1.25rem; }
.stat-card .small { font-size: 0.75rem; }
.section-title { display:flex; align-items:center; gap:8px; font-weight:600; color:#495057; margin-bottom: 8px; }
.section-title .dot { width:8px; height:8px; border-radius:50%; background:#0d6efd; display:inline-block; }
.card-divider { height:1px; background:#e9ecef; margin: 8px 0 12px; }

@media (max-width: 992px) {
  .dashboard-grid .grid-col-3, .dashboard-grid .grid-col-4 { grid-column: span 6; }
}
@media (max-width: 576px) {
  .dashboard-grid .grid-col-3, .dashboard-grid .grid-col-4, .dashboard-grid .grid-col-6 { grid-column: span 12; }
}

:root {
    --primary-color: #007bff;
    --secondary-color: #6c757d;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #17a2b8;
    --light-color: #f8f9fa;
    --dark-color: #343a40;
    --border-radius: 0.375rem;
    --box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    --transition: all 0.15s ease-in-out;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    margin: 0;
    padding: 0;
}

.navbar {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    background: linear-gradient(135deg, var(--primary-color) 0%, #0056b3 100%) !important;
    padding: 1rem 0;
}

.navbar-brand {
    font-weight: 600;
    font-size: 1.5rem;
    color: white !important;
}

.nav-link {
    font-weight: 500;
    transition: var(--transition);
    color: rgba(255, 255, 255, 0.8) !important;
}

.nav-link:hover {
    color: white !important;
}

.nav-link.active {
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: var(--border-radius);
    color: white !important;
}

.card {
    border: none;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    transition: var(--transition);
    background: white;
    margin-bottom: 1.5rem;
}

.card:hover {
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

.card-header {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-bottom: 1px solid #dee2e6;
    font-weight: 600;
    color: var(--dark-color);
    padding: 1rem 1.25rem;
}

/* User tracking badges */
.badge.bg-info {
    background-color: #17a2b8 !important;
    color: white;
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-weight: 500;
}

.badge.bg-info:hover {
    background-color: #138496 !important;
}

/* Appointment item styling */
.appointment-item {
    border: 1px solid #e9ecef;
    border-radius: 0.5rem;
    padding: 1rem;
    margin-bottom: 0.75rem;
    background: white;
    transition: all 0.2s ease;
}

.appointment-item:hover {
    box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.1);
}

.appointment-date {
    font-weight: 600;
    color: #495057;
    margin-bottom: 0.5rem;
}

.appointment-client {
    font-weight: 500;
    color: #6c757d;
    margin-bottom: 0.25rem;
}

.appointment-notes {
    color: #6c757d;
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
}

.appointment-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Table styling for appointments */
.table th {
    background-color: #f8f9fa;
    border-bottom: 2px solid #dee2e6;
    font-weight: 600;
    color: #495057;
}

.table td {
    vertical-align: middle;
    padding: 0.75rem;
}

.table-hover tbody tr:hover {
    background-color: #f8f9fa;
    transition: background-color 0.15s ease-in-out;
}

/* Sidebar Navigation Styles */
.sidebar {
    position: fixed;
    top: var(--mobile-top-bar-height, 0px);
    left: 0;
    height: calc(100vh - var(--mobile-top-bar-height, 0px));
    width: 260px;
    background: linear-gradient(180deg, #2c3e50 0%, #34495e 100%);
    color: white;
    z-index: 1050;
    transition: transform 0.3s ease;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
}

.sidebar.collapsed {
    transform: translateX(-220px);
}

.sidebar-header {
    padding: 1rem 1rem 0.75rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-brand {
    font-size: 1.1rem;
    font-weight: 600;
    color: white;
    display: flex;
    align-items: center;
}

.sidebar-brand i {
    font-size: 1.3rem;
    margin-right: 0.5rem;
    color: #3498db;
}

.sidebar-user {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.user-info i {
    font-size: 1.5rem;
    color: #3498db;
}

.user-info span {
    font-weight: 500;
    color: white;
    font-size: 0.9rem;
}

.sidebar-user .dropdown-toggle {
    color: rgba(255,255,255,0.8);
    padding: 0.25rem 0.5rem;
    font-size: 0.9rem;
}

.sidebar-user .dropdown-toggle:hover {
    color: white;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem 0;
}

.nav-menu {
    list-style: none;
    padding: 0;
    margin: 0;
}

.nav-menu .nav-item {
    margin: 0.15rem 0;
}

.nav-menu .nav-link {
    display: flex;
    align-items: center;
    padding: 0.6rem 1.25rem;
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
    font-size: 0.9rem;
}

.nav-menu .nav-link:hover {
    background-color: rgba(255,255,255,0.1);
    color: white;
    border-left-color: #3498db;
}

.nav-menu .nav-link.active {
    background-color: rgba(52, 152, 219, 0.2);
    color: white;
    border-left-color: #3498db;
}

.nav-menu .nav-link i {
    width: 18px;
    margin-right: 0.6rem;
    text-align: center;
    font-size: 0.9rem;
}



.sidebar-overlay {
    position: fixed;
    top: var(--mobile-top-bar-height, 0px);
    left: 0;
    width: 100%;
    height: calc(100vh - var(--mobile-top-bar-height, 0px));
    background-color: rgba(0,0,0,0.5);
    z-index: 1040;
    display: none;
}

/* Main content adjustment */
body {
    padding-left: 260px;
    transition: padding-left 0.3s ease;
}

body.sidebar-collapsed {
    padding-left: 40px;
}

/* Content wrapper */
.content-wrapper {
    min-height: 100vh;
    background-color: #f5f5f5;
}

.card-body {
    padding: 1.5rem;
}

.card.bg-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, #0056b3 100%) !important;
}

.card.bg-success {
    background: linear-gradient(135deg, var(--success-color) 0%, #1e7e34 100%) !important;
}

.card.bg-warning {
    background: linear-gradient(135deg, var(--warning-color) 0%, #e0a800 100%) !important;
}

.card.bg-info {
    background: linear-gradient(135deg, var(--info-color) 0%, #138496 100%) !important;
}

.btn {
    border-radius: var(--border-radius);
    font-weight: 500;
    transition: var(--transition);
    border: none;
    padding: 0.5rem 1rem;
    text-decoration: none;
    display: inline-block;
    text-align: center;
    cursor: pointer;
}

.btn:hover {
    box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.15);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, #0056b3 100%);
    color: white;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #0056b3 0%, #004085 100%);
    color: white;
}

.btn-success {
    background: linear-gradient(135deg, var(--success-color) 0%, #1e7e34 100%);
    color: white;
}

.btn-warning {
    background: linear-gradient(135deg, var(--warning-color) 0%, #e0a800 100%);
    color: #212529;
}

.btn-info {
    background: linear-gradient(135deg, var(--info-color) 0%, #138496 100%);
    color: white;
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger-color) 0%, #c82333 100%);
    color: white;
}

.btn-outline-primary {
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
    background: transparent;
}

.btn-outline-primary:hover {
    background: var(--primary-color);
    color: white;
}

.btn-outline-warning {
    border: 1px solid var(--warning-color);
    color: var(--warning-color);
    background: transparent;
}

.btn-outline-warning:hover {
    background: var(--warning-color);
    color: #212529;
}

.btn-outline-danger {
    border: 1px solid var(--danger-color);
    color: var(--danger-color);
    background: transparent;
}

.btn-outline-danger:hover {
    background: var(--danger-color);
    color: white;
}

.btn-outline-secondary {
    border: 1px solid var(--secondary-color);
    color: var(--secondary-color);
    background: transparent;
}

.btn-outline-secondary:hover {
    background: var(--secondary-color);
    color: white;
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
}

.form-control {
    border-radius: var(--border-radius);
    border: 1px solid #ced4da;
    transition: var(--transition);
    padding: 0.75rem;
    width: 100%;
    font-size: 1rem;
}

.form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
    outline: none;
}

.form-label {
    font-weight: 600;
    color: var(--dark-color);
    margin-bottom: 0.5rem;
    display: block;
}

.form-select {
    border-radius: var(--border-radius);
    border: 1px solid #ced4da;
    transition: var(--transition);
    padding: 0.75rem;
    width: 100%;
    font-size: 1rem;
}

.form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
    outline: none;
}

.table {
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--box-shadow);
    background: white;
    width: 100%;
    margin-bottom: 0;
}

.table thead th {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-bottom: 2px solid #dee2e6;
    font-weight: 600;
    color: var(--dark-color);
    text-transform: uppercase;
    font-size: 0.875rem;
    letter-spacing: 0.5px;
    padding: 1rem;
}

.table tbody tr {
    transition: var(--transition);
}

.table tbody tr:hover {
    background-color: rgba(0, 123, 255, 0.05);
}

.table tbody td {
    padding: 1rem;
    border-bottom: 1px solid #dee2e6;
    vertical-align: middle;
}

.badge {
    padding: 0.5rem 0.75rem;
    border-radius: var(--border-radius);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.bg-primary {
    background-color: var(--primary-color) !important;
}

.bg-success {
    background-color: var(--success-color) !important;
}

.bg-warning {
    background-color: var(--warning-color) !important;
    color: #212529;
}

.bg-danger {
    background-color: var(--danger-color) !important;
}

.bg-secondary {
    background-color: var(--secondary-color) !important;
}

.modal-content {
    border-radius: var(--border-radius);
    border: none;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

/* Higher specificity than Bootstrap (loaded after this file) so titles wrap instead of clipping */
body .modal .modal-header {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-bottom: 1px solid #dee2e6;
    padding: 1rem 1.5rem;
    align-items: flex-start;
    gap: 0.75rem;
}

body .modal .modal-title {
    font-weight: 600;
    color: var(--dark-color);
    margin: 0;
    flex: 1 1 auto;
    min-width: 0;
    overflow-wrap: break-word;
    word-break: break-word;
    line-height: 1.35;
}

body .modal .modal-header .btn-close {
    flex-shrink: 0;
    margin-top: 0.125rem;
    margin-left: auto;
}

/* Group when header has title + subtitle (e.g. drawing modal) */
body .modal .modal-title-group {
    flex: 1 1 auto;
    min-width: 0;
}

/* Tablets + phones: centered dialogs can clip headers when viewport is short */
@media (max-width: 991.98px) {
    body .modal .modal-dialog.modal-dialog-centered {
        min-height: 0 !important;
        align-items: flex-start;
        padding-top: 0.25rem;
        padding-bottom: 0.75rem;
    }
}

/*
 * Appointment modals (calendar + dashboard): <form> wraps .modal-body + .modal-footer.
 * Bootstrap’s scrollable modal assumes body/footer are direct flex children of .modal-content;
 * without this, the form grows past the viewport and the footer is clipped on desktop.
 *
 * max-height must NOT apply below 768px: an ID would override the mobile modal shell
 * (max-height: 100% / flex chain) and leave Annulla/Salva half off-screen until scroll.
 */
body.calendar-page #appointment-modal .modal-content,
body.dashboard-page #appointment-modal .modal-content {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

body.calendar-page #appointment-modal #appointment-form,
body.dashboard-page #appointment-modal #appointment-form {
    display: flex;
    flex-direction: column;
    min-height: 0;
    flex: 1 1 auto;
}

body.calendar-page #appointment-modal .modal-body,
body.dashboard-page #appointment-modal .modal-body {
    overflow-y: auto;
    min-height: 0;
    flex: 1 1 auto;
}

body.calendar-page #appointment-modal .modal-footer,
body.dashboard-page #appointment-modal .modal-footer {
    flex-shrink: 0;
}

@media (min-width: 768px) {
    body.calendar-page #appointment-modal .modal-content,
    body.dashboard-page #appointment-modal .modal-content {
        max-height: min(92vh, calc(100vh - 2rem));
    }

    body.calendar-page #appointment-details-modal .modal-content,
    body.dashboard-page #appointment-details-modal .modal-content {
        max-height: min(92vh, calc(100vh - 2rem));
    }
}

body.calendar-page #appointment-details-modal .modal-content,
body.dashboard-page #appointment-details-modal .modal-content {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

body.calendar-page #appointment-details-modal .modal-body,
body.dashboard-page #appointment-details-modal .modal-body {
    overflow-y: auto;
    min-height: 0;
    flex: 1 1 auto;
}

body.calendar-page #appointment-details-modal .modal-header,
body.calendar-page #appointment-details-modal .modal-footer,
body.dashboard-page #appointment-details-modal .modal-header,
body.dashboard-page #appointment-details-modal .modal-footer {
    flex-shrink: 0;
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    border-top: 1px solid #dee2e6;
    padding: 1rem 1.5rem;
}

.modal-xl {
    max-width: 90%;
}

.form-section {
    margin-bottom: 2rem;
}

.form-section h4 {
    color: var(--primary-color);
    font-weight: 600;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--primary-color);
}

.file-upload-area {
    position: relative;
    border: 2px dashed #dee2e6;
    border-radius: var(--border-radius);
    padding: 2rem;
    text-align: center;
    transition: var(--transition);
    background-color: #f8f9fa;
    margin-bottom: 1rem;
}

.file-upload-area:hover {
    border-color: var(--primary-color);
    background-color: rgba(0, 123, 255, 0.05);
}

.file-upload-area input[type="file"] {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
    top: 0;
    left: 0;
}

.file-upload-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    color: var(--secondary-color);
}

.upload-icon {
    font-size: 2rem;
}

.file-list {
    margin-top: 1rem;
}

.file-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem;
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: var(--border-radius);
    margin-bottom: 0.5rem;
}

.file-name {
    font-size: 0.875rem;
    color: var(--dark-color);
}

.remove-file {
    background: none;
    border: none;
    color: var(--danger-color);
    cursor: pointer;
    font-size: 1rem;
    padding: 0.25rem;
}

.remove-file:hover {
    color: #c82333;
}

.client-search-container {
    position: relative;
}

.client-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: var(--border-radius);
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    z-index: 1000;
    max-height: 300px;
    overflow-y: auto;
    display: none;
}

.client-option {
    padding: 0.75rem;
    cursor: pointer;
    transition: var(--transition);
    border-bottom: 1px solid #f8f9fa;
}

.client-option:hover {
    background-color: #f8f9fa;
}

.client-option:last-child {
    border-bottom: none;
}

.total-display {
    background: linear-gradient(135deg, var(--success-color) 0%, #1e7e34 100%);
    color: white;
    padding: 1.5rem;
    border-radius: var(--border-radius);
    text-align: center;
    box-shadow: var(--box-shadow);
}

.total-display h3 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
}

.extraction-info {
    background-color: #d4edda;
    border: 1px solid #c3e6cb;
    border-radius: var(--border-radius);
    padding: 1rem;
    margin-top: 1rem;
}

.btn-group {
    display: inline-flex;
    vertical-align: middle;
}

.btn-group .btn {
    border-radius: 0;
    margin-right: -1px;
}

.btn-group .btn:first-child {
    border-top-left-radius: var(--border-radius);
    border-bottom-left-radius: var(--border-radius);
}

.btn-group .btn:last-child {
    border-top-right-radius: var(--border-radius);
    border-bottom-right-radius: var(--border-radius);
    margin-right: 0;
}

.text-muted {
    color: var(--secondary-color) !important;
}

.text-center {
    text-align: center;
}

.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: 0.25rem !important; }
.mb-2 { margin-bottom: 0.5rem !important; }
.mb-3 { margin-bottom: 1rem !important; }
.mb-4 { margin-bottom: 1.5rem !important; }
.mt-1 { margin-top: 0.25rem !important; }
.mt-2 { margin-top: 0.5rem !important; }
.mt-3 { margin-top: 1rem !important; }
.mt-4 { margin-top: 1.5rem !important; }
.me-1 { margin-right: 0.25rem !important; }
.me-2 { margin-right: 0.5rem !important; }
.ms-1 { margin-left: 0.25rem !important; }
.ms-2 { margin-left: 0.5rem !important; }

.d-flex { display: flex !important; }
.justify-content-between { justify-content: space-between !important; }
.justify-content-center { justify-content: center !important; }
.align-items-center { align-items: center !important; }
.align-self-center { align-self: center !important; }

.text-white { color: white !important; }
.bg-white { background-color: white !important; }

@media (max-width: 768px) {
    .table-responsive {
        font-size: 0.875rem;
    }
    
    .btn {
        width: 100%;
        margin-bottom: 0.5rem;
    }
    
    .modal-xl {
        max-width: 95%;
        margin: 1rem;
    }
    
    .form-section h4 {
        font-size: 1.1rem;
    }
    
    .file-upload-area {
        padding: 1rem;
    }
    
    .upload-icon {
        font-size: 1.5rem;
    }
    
    .btn-group {
        flex-direction: column;
    }
    
    .btn-group .btn {
        border-radius: var(--border-radius) !important;
        margin-right: 0 !important;
        margin-bottom: 0.25rem;
    }
}

/* Calendar styles */
.calendar-grid {
    display: grid;
    gap: 12px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.calendar-row {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
}

.calendar-row.header .calendar-cell {
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
    border: none;
    text-align: center;
    font-weight: 700;
    color: white;
    min-height: 50px;
    padding: 15px 8px;
    border-radius: 8px;
    text-transform: uppercase;
    font-size: 0.9rem;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.calendar-cell {
    background: white;
    border: 2px solid #e9ecef;
    border-radius: 12px;
    min-height: 120px;
    padding: 12px;
    position: relative;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

.calendar-cell:hover {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-color: #007bff;
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.15);
}

.calendar-cell.empty {
    background: #f8f9fa;
    border: 2px dashed #dee2e6;
    cursor: default;
    opacity: 0.6;
}

.calendar-cell.empty:hover {
    background: #f8f9fa;
    border-color: #dee2e6;
    transform: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.calendar-cell.today {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    border-color: #28a745;
    color: white;
}

.calendar-cell.today .day-number {
    color: white;
}

.day-number {
    font-weight: 700;
    color: #495057;
    margin-bottom: 8px;
    font-size: 1.1rem;
    text-align: center;
    background: rgba(0, 123, 255, 0.1);
    border-radius: 50%;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 8px auto;
}

.calendar-cell.today .day-number {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.badge-wrap {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: auto;
}

.badge {
    font-size: 0.7rem;
    padding: 4px 8px;
    border-radius: 12px;
    color: white;
    display: inline-block;
    text-align: center;
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.badge.mounting {
    background: linear-gradient(135deg, #ff6b35 0%, #f7931e 100%);
}

.badge.appointment {
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
}

/* Calendar controls styling */
.calendar-controls {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
}

#current-month-display {
    font-size: 1.5rem;
    font-weight: 700;
    color: #495057;
    text-transform: capitalize;
}

.calendar-controls .btn {
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
    border: none;
    color: white;
    padding: 10px 15px;
    border-radius: 8px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.calendar-controls .btn:hover {
    background: linear-gradient(135deg, #0056b3 0%, #004085 100%);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.appointments-container {
    max-height: 400px;
    overflow-y: auto;
    padding: 10px;
}

.appointment-item {
    border: 2px solid #e9ecef;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
    background: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.appointment-item:hover {
    border-color: #007bff;
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.15);
}

.appointment-date {
    font-weight: 700;
    color: #007bff;
    margin-bottom: 8px;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.appointment-date::before {
    content: "📅";
    font-size: 1.2rem;
}

.appointment-client {
    color: #495057;
    margin-bottom: 8px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.appointment-client::before {
    content: "👤";
    font-size: 1.1rem;
}

.appointment-notes {
    color: #6c757d;
    font-size: 0.95rem;
    margin-bottom: 12px;
    padding: 8px 12px;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid #007bff;
}

.appointment-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.appointment-actions .btn {
    padding: 6px 12px;
    font-size: 0.85rem;
    border-radius: 8px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.appointment-actions .btn:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Empty state styling */
.appointments-container p {
    text-align: center;
    color: #6c757d;
    font-style: italic;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 2px dashed #dee2e6;
}

/* Today and Tomorrow sections styling */
#today-list .appointment-item {
    border-left: 4px solid #28a745;
    background: linear-gradient(135deg, #f8fff9 0%, #ffffff 100%);
}

#tomorrow-list .appointment-item {
    border-left: 4px solid #ffc107;
    background: linear-gradient(135deg, #fffdf8 0%, #ffffff 100%);
}

#today-list .appointment-date {
    color: #28a745;
    font-weight: bold;
}

#tomorrow-list .appointment-date {
    color: #ffc107;
    font-weight: bold;
}

/* Dashboard: compact Today & Tomorrow (less space, scrollable) */
.dashboard-today-tomorrow .card-header {
    font-size: 0.95rem;
}

.dashboard-appointments-list,
.compact-appointments-list {
    max-height: 200px;
    overflow-y: auto;
    overflow-x: hidden;
}

.dashboard-appointments-list .appointment-item,
.compact-appointments-list .appointment-item {
    padding: 0.4rem 0.5rem;
    margin-bottom: 0.35rem;
    border-radius: 0.35rem;
}

.dashboard-appointments-list .appointment-date,
.compact-appointments-list .appointment-date {
    font-size: 0.8rem;
    margin-bottom: 0.2rem;
}

.dashboard-appointments-list .appointment-date .badge,
.compact-appointments-list .appointment-date .badge {
    font-size: 0.65rem;
    padding: 0.15em 0.4em;
    margin-left: 0.25rem !important;
}

.dashboard-appointments-list .appointment-client,
.compact-appointments-list .appointment-client {
    font-size: 0.85rem;
    margin-bottom: 0.15rem;
}

.dashboard-appointments-list .appointment-phone,
.compact-appointments-list .appointment-phone {
    font-size: 0.75rem;
    margin-bottom: 0.15rem;
}

.dashboard-appointments-list .appointment-notes,
.compact-appointments-list .appointment-notes {
    font-size: 0.75rem;
    margin-bottom: 0.35rem;
    max-height: 2.2em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dashboard-appointments-list .appointment-actions,
.compact-appointments-list .appointment-actions {
    gap: 0.2rem;
    flex-wrap: nowrap;
    display: flex;
    width: 100%;
}

.dashboard-appointments-list .appointment-actions .btn:last-child,
.dashboard-appointments-list .appointment-actions .btn-sm:last-child,
.compact-appointments-list .appointment-actions .btn:last-child,
.compact-appointments-list .appointment-actions .btn-sm:last-child {
    margin-left: auto;
}

.dashboard-appointments-list .appointment-actions .btn,
.dashboard-appointments-list .appointment-actions .btn-sm,
.compact-appointments-list .appointment-actions .btn,
.compact-appointments-list .appointment-actions .btn-sm {
    padding: 0.15rem 0.3rem;
    font-size: 0.7rem;
    line-height: 1.2;
    white-space: nowrap;
    flex-shrink: 0;
}

.dashboard-appointments-list .text-muted,
.compact-appointments-list .text-muted {
    font-size: 0.8rem;
    padding: 0.35rem 0;
}

/* Calendar: compact card headers */
.calendar-compact-card .card-header {
    font-size: 0.95rem;
}

/* Mobile: dashboard Today & Tomorrow, compact lists, day-appointments buttons */
@media (max-width: 768px) {
    .dashboard-today-tomorrow .card-body {
        padding: 0.5rem 0.75rem;
    }

    .dashboard-appointments-list,
    .compact-appointments-list {
        max-height: 160px;
    }

    .dashboard-appointments-list .appointment-item,
    .compact-appointments-list .appointment-item {
        padding: 0.35rem 0.4rem;
    }

    .dashboard-appointments-list .appointment-date,
    .compact-appointments-list .appointment-date {
        font-size: 0.75rem;
    }

    .dashboard-appointments-list .appointment-client,
    .compact-appointments-list .appointment-client {
        font-size: 0.8rem;
    }

    .dashboard-appointments-list .appointment-notes,
    .compact-appointments-list .appointment-notes {
        display: none;
    }

    .dashboard-appointments-list .appointment-actions,
    .compact-appointments-list .appointment-actions {
        flex-direction: row;
        flex-wrap: nowrap;
    }
    .dashboard-appointments-list .appointment-actions .btn,
    .dashboard-appointments-list .appointment-actions .btn-sm,
    .compact-appointments-list .appointment-actions .btn,
    .compact-appointments-list .appointment-actions .btn-sm {
        padding: 0.2rem 0.35rem;
        font-size: 0.75rem;
        min-height: 28px;
        flex-shrink: 0;
        width: auto;
    }

    .day-appointments .btn-group-vertical .btn {
        padding: 0.25rem 0.45rem;
        font-size: 0.8rem;
    }
}

/* Day appointments modal (calendar): compact row buttons, no stretch */
.day-appointments .appointment-item {
    padding: 0.5rem 0.6rem;
    margin-bottom: 0.5rem;
}

.day-appointments .btn-group-vertical {
    display: inline-flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap;
    width: auto;
    min-width: 0;
    gap: 0.25rem;
    flex-shrink: 0;
}

.day-appointments .btn-group-vertical .btn {
    padding: 0.35rem 0.5rem;
    font-size: 0.8rem;
    flex-shrink: 0;
    width: auto;
    white-space: nowrap;
}

.day-appointments .btn-group-vertical .btn:last-child {
    margin-left: 0;
}

/* ==================== EXPENSES CALENDAR STYLES ==================== */

.calendar-grid {
    width: 100%;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    overflow: hidden;
    background: white;
}

.calendar-header {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-bottom: 2px solid #dee2e6;
}

.calendar-day-header {
    padding: 12px 8px;
    text-align: center;
    font-weight: 600;
    color: #495057;
    font-size: 0.9rem;
    border-right: 1px solid #dee2e6;
}

.calendar-day-header:last-child {
    border-right: none;
}

.calendar-body {
    display: flex;
    flex-direction: column;
}

.calendar-week {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    min-height: 80px;
}

.calendar-day {
    border-right: 1px solid #dee2e6;
    border-bottom: 1px solid #dee2e6;
    padding: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    min-height: 80px;
    display: flex;
    flex-direction: column;
}

.calendar-day:last-child {
    border-right: none;
}

.calendar-day:hover {
    background-color: #f8f9fa;
    z-index: 1;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.calendar-day.current-month {
    background-color: white;
}

.calendar-day.other-month {
    background-color: #f8f9fa;
    color: #6c757d;
}

.calendar-day.today {
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    border: 2px solid #2196f3;
    font-weight: bold;
}

.calendar-date {
    font-size: 0.9rem;
    font-weight: 600;
    color: #495057;
    margin-bottom: 4px;
}

.calendar-day.other-month .calendar-date {
    color: #adb5bd;
}

.calendar-day.today .calendar-date {
    color: #1976d2;
}

/* Mobile-only: count badge (replaces chips on small screens) */
.calendar-day-count {
    display: none;
    pointer-events: none; /* never capture click – day cell handles it (desktop + mobile) */
}

.calendar-expenses {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 4px;
    background: rgba(40, 167, 69, 0.1);
    border-radius: 4px;
    margin-top: 4px;
}

.expense-count {
    font-size: 0.7rem;
    font-weight: 600;
    color: #28a745;
    margin-bottom: 2px;
}

.expense-total {
    font-size: 0.8rem;
    font-weight: bold;
    color: #155724;
}

.calendar-day:hover .calendar-expenses {
    background: rgba(40, 167, 69, 0.2);
}

/* Calendar: responsive grid, calendar page, day-appointments modals (single mobile breakpoint) */
@media (max-width: 768px) {
    .calendar-day {
        min-height: 60px;
        padding: 4px;
    }
    
    .calendar-date {
        font-size: 0.8rem;
    }
    
    .expense-count {
        font-size: 0.6rem;
    }
    
    .expense-total {
        font-size: 0.7rem;
    }
    
    .calendar-day-header {
        padding: 8px 4px;
        font-size: 0.8rem;
    }
    
    /* Appointments calendar: short day labels (L M M G V S D) */
    #calendar-grid .calendar-day-header .day-label-full {
        display: none;
    }
    #calendar-grid .calendar-day-header::before {
        content: attr(data-short);
        font-size: 0.85rem;
        font-weight: 600;
        color: #495057;
    }
    
    /* Appointments calendar: sticky header + scrollable grid */
    #calendar-grid {
        max-height: 65vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    #calendar-grid .calendar-header {
        position: sticky;
        top: 0;
        z-index: 2;
        background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
        border-bottom: 2px solid #dee2e6;
    }
    
    /* Appointments calendar: show count badge, hide chips on mobile */
    #calendar-grid .calendar-day-count {
        display: flex;
        align-items: center;
        justify-content: center;
        min-width: 22px;
        height: 22px;
        padding: 0 6px;
        font-size: 0.75rem;
        font-weight: 700;
        color: #fff;
        background: #007bff;
        border-radius: 50%;
        margin-top: 2px;
        pointer-events: none; /* tap goes to day cell to open appointments */
    }
    #calendar-grid .calendar-appointments {
        display: none !important;
    }
    
    /* Bigger tap targets for calendar days */
    #calendar-grid .calendar-day {
        min-height: 52px;
        padding: 10px 6px;
    }
    #calendar-grid .calendar-date {
        min-height: 28px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 0.95rem;
    }
    
    /* Simpler controls: hide year arrows on mobile (month arrows + swipe are enough) */
    .calendar-year-btn {
        display: none !important;
    }

    .calendar-page .calendar-page-header {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }
    .calendar-page .calendar-page-title {
        font-size: 1.35rem;
        text-align: center;
    }
    .calendar-page .btn-new-appointment {
        width: 100%;
        min-height: 44px;
        justify-content: center;
    }
    .calendar-page .calendar-card-footer .btn {
        width: 100%;
        min-height: 44px;
    }
    .calendar-page .calendar-controls .d-flex {
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.5rem;
    }
    .calendar-page .calendar-controls .btn:not(.calendar-year-btn) {
        min-width: 44px;
        min-height: 44px;
        padding: 0.5rem;
    }
    .calendar-page #current-month-display {
        width: 100%;
        text-align: center;
        font-size: 1.1rem;
        order: -1;
        margin-bottom: 0.25rem;
    }
    /* Today / Tomorrow / Monthly cards */
    .calendar-page .card-header h5 {
        font-size: 1rem;
    }
    .calendar-page .card-body {
        padding: 1rem;
    }
    /* Year overview: touch-friendly mini months */
    .calendar-page #year-overview .p-2.border.rounded {
        padding: 0.75rem !important;
    }
    .calendar-page #year-overview [style*="gridTemplateColumns"] {
        min-height: 44px;
    }
    .calendar-page #year-overview .text-center.border.rounded[style*="cursor"] {
        min-height: 32px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 0.8rem;
    }
    /* Appointments table: smooth scroll, readable */
    .calendar-page .calendar-table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin-left: -0.5rem;
        margin-right: -0.5rem;
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }
    .calendar-page .calendar-table-card .table {
        font-size: 0.8rem;
        min-width: 700px;
    }
    .calendar-page .calendar-table-card .table th,
    .calendar-page .calendar-table-card .table td {
        padding: 0.5rem 0.35rem;
        white-space: nowrap;
    }
    .calendar-page .calendar-table-card .table .btn-group .btn {
        min-width: 36px;
        min-height: 36px;
        padding: 0.35rem;
    }

    .calendar-page .day-appointments .d-flex.justify-content-between.align-items-center.mb-3 {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    .calendar-page .day-appointments .appointment-item {
        flex-direction: column;
        align-items: stretch;
    }
    .calendar-page .day-appointments .appointment-item .d-flex.justify-content-between.align-items-start {
        flex-direction: column;
        gap: 0.75rem;
    }
    .calendar-page .day-appointments .btn-group-vertical {
        flex-direction: row !important;
        justify-content: flex-end;
        gap: 0.5rem;
        width: auto !important;
    }
    .calendar-page .day-appointments .btn-group-vertical .btn {
        min-width: 44px;
        min-height: 44px;
        padding: 0.5rem;
        width: auto;
    }
    .calendar-page .day-appointments .modal-footer {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    .calendar-page .day-appointments .modal-footer .btn {
        flex: 1;
        min-width: 140px;
        min-height: 44px;
    }
    /* Appointment form modal – touch-friendly inputs and buttons */
    .calendar-page #appointment-modal .form-control,
    .calendar-page #appointment-modal .form-select {
        min-height: 44px;
    }
    .calendar-page #appointment-modal .modal-footer .btn {
        min-height: 44px;
        flex: 1;
    }
    .calendar-page #appointment-details-modal .modal-footer .btn {
        min-height: 44px;
    }
    .calendar-page #move-appointment-modal #move-appointment-date {
        min-height: 48px;
        font-size: 1.1rem;
    }
    .calendar-page #move-appointment-modal .modal-footer .btn {
        min-height: 44px;
    }
}

/* ==================== MOBILE OPTIMIZATION ENHANCEMENTS ==================== */

/* Enhanced Mobile Responsiveness */
@media (max-width: 1200px) {
    .dashboard-grid .grid-col-3 { grid-column: span 4; }
    .dashboard-grid .grid-col-4 { grid-column: span 6; }
    .dashboard-grid .grid-col-6 { grid-column: span 8; }
}

@media (max-width: 992px) {
    .dashboard-grid .grid-col-3, .dashboard-grid .grid-col-4 { grid-column: span 6; }
    .dashboard-grid .grid-col-6 { grid-column: span 12; }
    
    /* Improve card layouts on tablets */
    .card-body { padding: 1.25rem; }
    .btn { padding: 0.6rem 1.2rem; font-size: 0.95rem; }
}

@media (max-width: 768px) {
    /* Mobile-first improvements */
    .container-fluid { padding: 0.75rem; }

    /*
     * Mobile top bar: menu button lives in a fixed strip with safe-area insets.
     * body padding + --mobile-top-bar-height push page content below the strip.
     * Modals/backdrop and sidebar/overlay use the same offset so they sit under the bar, not behind it.
     */
    body.mobile-top-bar-offset {
        --mobile-top-bar-height: calc(env(safe-area-inset-top, 0px) + 0.75rem + 2.75rem + 0.75rem);
        padding-top: var(--mobile-top-bar-height);
        /* Match curved / notched screen edges so content and the menu strip don’t bleed past the glass */
        padding-left: env(safe-area-inset-left, 0px);
        padding-right: env(safe-area-inset-right, 0px);
    }

    .mobile-sidebar-toggle {
        position: fixed;
        top: calc(env(safe-area-inset-top, 0px) + 0.75rem);
        /* Align with container inner edge: safe area + same gutter as .container-fluid */
        left: calc(env(safe-area-inset-left, 0px) + 0.75rem);
        right: auto;
        z-index: 1090;
        padding: 0.5rem 0.75rem;
        font-size: 1rem;
        border-radius: 0.5rem;
        box-sizing: border-box;
        /* Tighter shadow so it doesn’t read as extending past the screen edge */
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.14);
        max-width: calc(100vw - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px) - 1.5rem);
    }
    
    /* Enhanced mobile sidebar navigation */
    .sidebar {
        transform: translateX(-100%);
        width: 240px; /* Smaller width for mobile */
        z-index: 1085; /* Below menu button, above modals */
    }
    
    .sidebar.mobile-open {
        transform: translateX(0);
        box-shadow: 4px 0 20px rgba(0,0,0,0.3);
    }

    .sidebar-overlay.mobile-open {
        display: block;
    }
    
    body {
        padding-left: 0;
        font-size: 16px; /* Prevent zoom on iOS */
    }
    
    /* Enhanced card styling for mobile */
    .card {
        margin-bottom: 1rem;
        border-radius: 0.75rem;
    }
    
    .card-body {
        padding: 1rem;
    }
    
    /* Touch-friendly buttons */
    .btn {
        min-height: 44px; /* iOS recommended touch target */
        padding: 0.75rem 1rem;
        font-size: 1rem;
        border-radius: 0.5rem;
        margin-bottom: 0.5rem;
    }
    
    .btn-sm {
        min-height: 36px;
        padding: 0.5rem 0.75rem;
    }
    
    /* Mobile-optimized forms */
    .form-control, .form-select {
        min-height: 44px;
        font-size: 16px; /* Prevent zoom on iOS */
        padding: 0.75rem;
        border-radius: 0.5rem;
    }
    
    .form-label {
        font-size: 0.95rem;
        margin-bottom: 0.5rem;
    }
    
    /* Mobile table improvements */
    .table-responsive {
        border-radius: 0.5rem;
        overflow: hidden;
        box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    }
    
    .table {
        font-size: 0.875rem;
    }
    
    .table th, .table td {
        padding: 0.75rem 0.5rem;
        vertical-align: middle;
    }
    
    /* Modals sit below the mobile top bar (layout), not only under z-index */
    .modal {
        --bs-modal-zindex: 1070;
    }
    .modal-backdrop {
        --bs-backdrop-zindex: 1065;
    }
    body.mobile-top-bar-offset .modal {
        top: var(--mobile-top-bar-height);
        left: 0;
        width: 100%;
        height: calc(100vh - var(--mobile-top-bar-height));
        min-height: 0;
        overflow-x: hidden;
        overflow-y: auto;
    }
    body.mobile-top-bar-offset .modal-backdrop {
        top: var(--mobile-top-bar-height);
        left: 0;
        width: 100%;
        height: calc(100vh - var(--mobile-top-bar-height));
    }

    .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
    }

    .modal-content {
        border-radius: 0.75rem;
    }
    
    body .modal .modal-header {
        padding: 1rem;
    }
    
    body .modal .modal-body {
        padding: 1rem;
    }
    
    body .modal .modal-footer {
        padding: 1rem;
        flex-direction: column;
        gap: 0.5rem;
    }
    
    body .modal .modal-footer .btn {
        width: 100%;
        margin: 0;
    }
    
    /* Mobile calendar improvements (appointments grid uses #calendar-grid rules above) */
    .calendar-grid:not(#calendar-grid) {
        padding: 0.75rem;
        gap: 8px;
    }
    
    .calendar-cell {
        min-height: 80px;
        padding: 8px;
    }
    
    .calendar-day {
        min-height: 60px;
        padding: 6px;
    }
    
    /* Mobile appointment calendar styles */
    .calendar-appointments {
        flex-grow: 1;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        text-align: center;
        gap: 2px;
    }
    
    .appointment-count {
        font-size: 0.7rem;
        font-weight: 600;
        padding: 2px 4px;
        border-radius: 4px;
        background: rgba(0, 123, 255, 0.1);
        color: #007bff;
        white-space: nowrap;
    }
    
    .appointment-count.mounting {
        background: rgba(255, 193, 7, 0.2);
        color: #ffc107;
    }
    
    .appointment-count.other {
        background: rgba(40, 167, 69, 0.2);
        color: #28a745;
    }
    
    .appointment-chip {
        font-size: 0.65rem;
        padding: 2px 4px;
        border-radius: 4px;
        background: rgba(0, 123, 255, 0.15);
        color: #004085;
        cursor: grab;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
    }
    .appointment-chip:hover {
        background: rgba(0, 123, 255, 0.25);
    }
    .appointment-chip.dragging {
        opacity: 0.6;
        cursor: grabbing;
    }
    .appointment-chip-touch {
        cursor: pointer;
        min-height: 44px;
        min-width: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        padding: 6px 8px;
    }
    .calendar-day.drop-target {
        background: rgba(40, 167, 69, 0.2) !important;
        outline: 2px dashed #28a745;
    }
    
    .calendar-day:hover .calendar-appointments {
        background: rgba(0, 123, 255, 0.1);
    }
    
    /* Day appointments modal styles */
    .day-appointments .appointment-item {
        transition: all 0.2s ease;
    }
    
    .day-appointments .appointment-item:hover {
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    }
    
    .day-appointments .btn-group-vertical .btn {
        margin-bottom: 2px;
    }
    
    .day-appointments .btn-group-vertical .btn:last-child {
        margin-bottom: 0;
    }
    
    /* Mobile appointment improvements */
    .appointment-item {
        padding: 1rem;
        margin-bottom: 0.75rem;
    }
    
    .appointment-actions {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .appointment-actions .btn {
        width: 100%;
        margin: 0;
    }
    
    /* Enhanced mobile sidebar improvements */
    .sidebar-nav .nav-link {
        padding: 0.75rem 0.875rem;
        font-size: 0.95rem;
        min-height: 48px;
        display: flex;
        align-items: center;
        border-radius: 0.5rem;
        margin: 0.2rem 0.4rem;
    }
    
    .sidebar-nav .nav-link i {
        width: 24px;
        font-size: 1.1rem;
        margin-right: 0.75rem;
    }
    
    .sidebar-nav .nav-link:hover {
        background-color: rgba(255,255,255,0.15);
    }
    
    .sidebar-nav .nav-link.active {
        background-color: rgba(52, 152, 219, 0.3);
        border-left-color: #3498db;
        border-left-width: 4px;
    }
    
    /* Mobile sidebar header improvements */
    .sidebar-header {
        padding: 1rem 0.875rem;
        border-bottom: 2px solid rgba(255,255,255,0.1);
    }
    
    .sidebar-brand {
        font-size: 1.1rem;
        font-weight: 700;
    }
    
    .sidebar-brand i {
        font-size: 1.3rem;
        margin-right: 0.75rem;
    }
    
    /* Mobile sidebar user section improvements */
    .sidebar-user {
        padding: 0.875rem;
        border-bottom: 1px solid rgba(255,255,255,0.1);
    }
    
    .user-info {
        gap: 0.625rem;
    }
    
    .user-info i {
        font-size: 1.5rem;
    }
    
    .user-info span {
        font-size: 0.95rem;
        font-weight: 600;
    }
    
    /* Mobile overlay improvements */
    .sidebar-overlay.mobile-open {
        display: block;
        backdrop-filter: blur(3px);
        background-color: rgba(0,0,0,0.6);
    }
    
    /* Mobile dashboard improvements */
    .dashboard-compact .card-body {
        padding: 1rem;
    }
    
    .dashboard-compact .quick-card .btn {
        width: 100%;
        max-width: none;
    }
    
    /* Mobile file upload improvements */
    .file-upload-area {
        padding: 1.5rem 1rem;
    }
    
    .file-upload-label {
        font-size: 1rem;
    }
    
    /* Mobile badge improvements */
    .badge {
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
        min-height: 32px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Mobile content wrapper improvements */
    .content-wrapper {
        padding-top: 0;
    }
    
    /* Mobile page header improvements */
    .content-wrapper h1 {
        font-size: 1.75rem;
        margin-bottom: 1rem;
        padding-top: 0.5rem;
    }
}

@media (max-width: 576px) {
    /* Small mobile optimizations */
    .dashboard-grid .grid-col-3, 
    .dashboard-grid .grid-col-4, 
    .dashboard-grid .grid-col-6 { 
        grid-column: span 12; 
    }
    
    .container-fluid {
        padding: 0.5rem;
    }
    
    /* Extra small mobile improvements */
    .card-body {
        padding: 0.75rem;
    }
    
    .btn {
        padding: 0.875rem 1rem;
        font-size: 1rem;
    }
    
    /* Mobile form improvements */
    .form-section {
        margin-bottom: 1.5rem;
    }
    
    .form-section h4 {
        font-size: 1.1rem;
        margin-bottom: 0.75rem;
    }
    
    /* Mobile table improvements */
    .table {
        font-size: 0.8rem;
    }
    
    .table th, .table td {
        padding: 0.5rem 0.25rem;
    }
    
    /* Mobile calendar improvements */
    .calendar-controls {
        padding: 1rem;
        margin-bottom: 1rem;
    }
    
    #current-month-display {
        font-size: 1.25rem;
    }
    
    .calendar-controls .btn {
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
    }
    
    /* Mobile modal improvements */
    .modal-dialog {
        margin: 0.25rem;
        max-width: calc(100% - 0.5rem);
    }
    
    .modal-content {
        border-radius: 0.5rem;
    }
    
    body .modal .modal-header,
    body .modal .modal-body,
    body .modal .modal-footer {
        padding: 0.75rem;
    }
    
    /* Mobile sidebar improvements */
    .sidebar {
        width: 260px;
    }
    
    .sidebar-header {
        padding: 1rem;
    }
    
    .sidebar-user {
        padding: 0.75rem;
    }
    
    /* Mobile navigation improvements */
    .nav-menu .nav-item {
        margin: 0.15rem 0;
    }
    
    .nav-menu .nav-link {
        padding: 1rem;
        font-size: 0.95rem;
        margin: 0.15rem 0.25rem;
    }
    

}

/* Touch-friendly improvements for all devices */
@media (hover: none) and (pointer: coarse) {
    /* Touch device optimizations */
    .btn:hover {
        transform: none;
    }
    
    .card:hover {
        transform: none;
    }
    
    .nav-link:hover {
        transform: none;
    }
    
    /* Larger touch targets */
    .dropdown-toggle {
        min-height: 44px;
        padding: 0.75rem;
    }
    
    .form-check-input {
        width: 1.25rem;
        height: 1.25rem;
    }
    
    /* Better touch feedback */
    .btn:active {
    }
    
    .card:active {
    }
    
    /* Sidebar touch improvements */
    .sidebar-nav .nav-link:active {
        background-color: rgba(255,255,255,0.2);
    }
}

/* Landscape mobile optimizations */
@media (max-width: 768px) and (orientation: landscape) {
    .sidebar {
        width: 240px;
    }
    
    .modal-dialog {
        max-height: 90vh;
        overflow-y: auto;
    }
    
    .calendar-cell {
        min-height: 60px;
    }
    
    .appointment-item {
        padding: 0.75rem;
    }
}

/* High DPI display optimizations */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .btn, .form-control, .card {
        border-width: 0.5px;
    }
}

/* Dark mode support for mobile */
@media (prefers-color-scheme: dark) {
    .sidebar {
        background: linear-gradient(180deg, #1a1a1a 0%, #2d2d2d 100%);
    }
    
    .card {
        background: #2d2d2d;
        color: #ffffff;
    }
    
    .form-control, .form-select {
        background: #2d2d2d;
        color: #ffffff;
        border-color: #404040;
    }
}

/* Accessibility improvements for mobile */
@media (prefers-reduced-motion: reduce) {
    .btn, .card, .nav-link, .sidebar {
        transition: none;
    }
    
    .btn:hover, .card:hover, .nav-link:hover {
        transform: none;
    }
}

/* Print styles for mobile */
@media print {
    .sidebar, .btn, .modal {
        display: none !important;
    }
    
    body {
        padding-left: 0 !important;
    }
    
    .card {
        box-shadow: none;
        border: 1px solid #000;
    }
}

/* Reports page - user-friendly layout */
.reports-options-card {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border: 1px solid #e2e8f0;
}
.reports-options-card .card-title {
    color: #334155;
    font-size: 1.1rem;
}
.report-output-card .card-body {
    min-height: 200px;
}
@media (max-width: 768px) {
    .reports-options-card .card-body,
    .report-output-card .card-body {
        padding: 1rem !important;
    }
}

/* Sales Summary stat cards - compact cards, normal-sized numbers */
.report-stat-card {
    margin-bottom: 0;
}
.report-stat-card .card-body {
    padding: 0.5rem 0.65rem !important;
    min-height: 0;
}
.report-stat-card h4 {
    line-height: 1.2;
}
.report-stat-card small {
    font-size: 0.75rem;
    display: block;
    margin-top: 0.1rem;
}
.report-stat-cards .card:hover {
    transform: none;
}

/* Order Status doughnut chart - smaller size */
.report-doughnut-wrap {
    max-width: 260px;
    max-height: 260px;
    margin: 0 auto;
}
.report-doughnut-wrap canvas {
    max-width: 100%;
    max-height: 100%;
}

/* PDF capture: don't clip charts, avoid page break inside chart blocks */
.report-pdf-capture .report-doughnut-wrap,
.report-pdf-capture .report-chart-block .card-body {
    max-height: none !important;
    overflow: visible !important;
}
.report-pdf-capture .report-chart-block {
    page-break-inside: avoid;
}
body:has(.report-pdf-capture) .report-output-card .card-body {
    overflow: visible !important;
    max-height: none !important;
}

/*
 * Calendar / Rimanenze / Ordini / Spese / Dashboard — long modals on mobile:
 * only .modal-body scrolls; Salva/footer stays fully visible (same idea as project-measurements).
 */
@media (max-width: 767.98px) {
    body.calendar-page .modal.show,
    body.rimanenze-page .modal.show,
    body.orders-to-finish-page .modal.show,
    body.expenses-page .modal.show,
    body.dashboard-page .modal.show {
        display: flex !important;
        flex-direction: column;
        align-items: stretch;
        justify-content: flex-start;
        box-sizing: border-box;
        min-height: 0;
        padding-top: 0;
        padding-bottom: max(0.25rem, env(safe-area-inset-bottom, 0px));
    }

    body.mobile-top-bar-offset.calendar-page .modal.show,
    body.mobile-top-bar-offset.rimanenze-page .modal.show,
    body.mobile-top-bar-offset.orders-to-finish-page .modal.show,
    body.mobile-top-bar-offset.expenses-page .modal.show,
    body.mobile-top-bar-offset.dashboard-page .modal.show {
        height: calc(100dvh - var(--mobile-top-bar-height)) !important;
        max-height: calc(100svh - var(--mobile-top-bar-height)) !important;
        overflow: hidden !important;
    }

    body.calendar-page .modal.show .modal-dialog.modal-dialog-scrollable,
    body.rimanenze-page .modal.show .modal-dialog.modal-dialog-scrollable,
    body.orders-to-finish-page .modal.show .modal-dialog.modal-dialog-scrollable,
    body.expenses-page .modal.show .modal-dialog.modal-dialog-scrollable,
    body.dashboard-page .modal.show .modal-dialog.modal-dialog-scrollable {
        flex: 1 1 auto;
        min-height: 0;
        max-height: 100%;
        overflow: hidden;
        margin-top: 0;
        margin-left: auto;
        margin-right: auto;
        margin-bottom: max(0.35rem, env(safe-area-inset-bottom, 0px));
        width: 100%;
        display: flex;
        flex-direction: column;
        padding-top: 0 !important;
        padding-bottom: 0 !important;
    }

    body:not(.mobile-top-bar-offset).calendar-page .modal.show .modal-dialog.modal-dialog-scrollable,
    body:not(.mobile-top-bar-offset).rimanenze-page .modal.show .modal-dialog.modal-dialog-scrollable,
    body:not(.mobile-top-bar-offset).orders-to-finish-page .modal.show .modal-dialog.modal-dialog-scrollable,
    body:not(.mobile-top-bar-offset).expenses-page .modal.show .modal-dialog.modal-dialog-scrollable,
    body:not(.mobile-top-bar-offset).dashboard-page .modal.show .modal-dialog.modal-dialog-scrollable {
        max-height: min(92dvh, 92vh);
    }

    body.mobile-top-bar-offset.calendar-page .modal.show .modal-dialog.modal-dialog-scrollable,
    body.mobile-top-bar-offset.rimanenze-page .modal.show .modal-dialog.modal-dialog-scrollable,
    body.mobile-top-bar-offset.orders-to-finish-page .modal.show .modal-dialog.modal-dialog-scrollable,
    body.mobile-top-bar-offset.expenses-page .modal.show .modal-dialog.modal-dialog-scrollable,
    body.mobile-top-bar-offset.dashboard-page .modal.show .modal-dialog.modal-dialog-scrollable {
        max-height: min(
            calc(100dvh - var(--mobile-top-bar-height, 0px) - 0.5rem),
            calc(100% - 0.25rem)
        );
    }

    body.calendar-page .modal.show .modal-dialog.modal-dialog-scrollable .modal-content,
    body.rimanenze-page .modal.show .modal-dialog.modal-dialog-scrollable .modal-content,
    body.orders-to-finish-page .modal.show .modal-dialog.modal-dialog-scrollable .modal-content,
    body.expenses-page .modal.show .modal-dialog.modal-dialog-scrollable .modal-content,
    body.dashboard-page .modal.show .modal-dialog.modal-dialog-scrollable .modal-content {
        display: flex;
        flex-direction: column;
        flex: 1 1 auto;
        min-height: 0;
        max-height: 100%;
        overflow: hidden;
    }

    body.calendar-page .modal.show .modal-dialog.modal-dialog-scrollable .modal-body,
    body.rimanenze-page .modal.show .modal-dialog.modal-dialog-scrollable .modal-body,
    body.orders-to-finish-page .modal.show .modal-dialog.modal-dialog-scrollable .modal-body,
    body.expenses-page .modal.show .modal-dialog.modal-dialog-scrollable .modal-body,
    body.dashboard-page .modal.show .modal-dialog.modal-dialog-scrollable .modal-body {
        flex: 1 1 auto;
        min-height: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }

    body.calendar-page .modal.show .modal-dialog.modal-dialog-scrollable .modal-header,
    body.calendar-page .modal.show .modal-dialog.modal-dialog-scrollable .modal-footer,
    body.rimanenze-page .modal.show .modal-dialog.modal-dialog-scrollable .modal-header,
    body.rimanenze-page .modal.show .modal-dialog.modal-dialog-scrollable .modal-footer,
    body.orders-to-finish-page .modal.show .modal-dialog.modal-dialog-scrollable .modal-header,
    body.orders-to-finish-page .modal.show .modal-dialog.modal-dialog-scrollable .modal-footer,
    body.expenses-page .modal.show .modal-dialog.modal-dialog-scrollable .modal-header,
    body.expenses-page .modal.show .modal-dialog.modal-dialog-scrollable .modal-footer,
    body.dashboard-page .modal.show .modal-dialog.modal-dialog-scrollable .modal-header,
    body.dashboard-page .modal.show .modal-dialog.modal-dialog-scrollable .modal-footer {
        flex-shrink: 0;
    }

    body.calendar-page .modal.show .modal-dialog.modal-dialog-scrollable .modal-footer,
    body.rimanenze-page .modal.show .modal-dialog.modal-dialog-scrollable .modal-footer,
    body.orders-to-finish-page .modal.show .modal-dialog.modal-dialog-scrollable .modal-footer,
    body.expenses-page .modal.show .modal-dialog.modal-dialog-scrollable .modal-footer,
    body.dashboard-page .modal.show .modal-dialog.modal-dialog-scrollable .modal-footer {
        padding-top: 0.65rem;
        padding-bottom: max(0.75rem, env(safe-area-inset-bottom, 0px));
    }
}

@media (max-width: 767.98px) and (orientation: landscape) {
    body.calendar-page .modal.show .modal-dialog.modal-dialog-scrollable,
    body.rimanenze-page .modal.show .modal-dialog.modal-dialog-scrollable,
    body.orders-to-finish-page .modal.show .modal-dialog.modal-dialog-scrollable,
    body.expenses-page .modal.show .modal-dialog.modal-dialog-scrollable,
    body.dashboard-page .modal.show .modal-dialog.modal-dialog-scrollable {
        max-height: min(
            calc(100dvh - var(--mobile-top-bar-height, 0px) - 0.5rem),
            100%
        ) !important;
        overflow: hidden !important;
    }
}

