/* BS Access CRM/ERP - Styles */
:root {
    /* Couleurs BS Access - Rouge / Gris / Blanc */
    --primary: #e53935;
    --primary-dark: #c62828;
    --primary-light: #ff6f60;
    --secondary: #5a5a5a;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #d32f2f;
    --info: #1976d2;
    --light: #fafafa;
    --dark: #4a4a4a;
    --white: #ffffff;
    --gray-100: #f5f5f5;
    --gray-200: #eeeeee;
    --gray-300: #e0e0e0;
    --gray-400: #bdbdbd;
    --gray-500: #9e9e9e;
    --gray-600: #757575;
    --gray-700: #616161;
    --gray-800: #424242;
    --sidebar-width: 260px;
    --header-height: 70px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.1);
    --radius: 8px;
    --transition: all 0.3s ease;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--gray-100);
    color: var(--gray-800);
    line-height: 1.6;
}

.hidden { display: none !important; }

/* Login Page */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #5a5a5a 0%, #3a3a3a 100%);
    padding: 20px;
}

.login-container {
    background: var(--white);
    padding: 40px;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 400px;
}

.login-logo {
    text-align: center;
    margin-bottom: 30px;
}

.login-logo .logo-img {
    max-width: 200px;
    height: auto;
    margin-bottom: 10px;
}

.login-logo p {
    color: var(--gray-500);
    font-size: 14px;
    font-weight: 500;
}

.login-form .form-group {
    margin-bottom: 20px;
}

.login-form label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--gray-700);
}

.login-form label i {
    margin-right: 8px;
    color: var(--gray-400);
}

.login-form input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: 16px;
    transition: var(--transition);
}

.login-form input:focus {
    outline: none;
    border-color: var(--primary);
}

.error-message {
    color: var(--danger);
    font-size: 14px;
    margin-top: 10px;
    text-align: center;
}

.login-footer {
    text-align: center;
    margin-top: 20px;
    color: var(--gray-500);
    font-size: 14px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

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

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--gray-200);
    color: var(--gray-700);
}

.btn-secondary:hover {
    background: var(--gray-300);
}

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

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

.btn-block {
    width: 100%;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 50%;
}

/* Main App Layout */
.main-app {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--white);
    color: var(--dark);
    position: fixed;
    height: 100vh;
    display: flex;
    flex-direction: column;
    transition: var(--transition);
    z-index: 100;
    border-right: 1px solid var(--gray-200);
}

.sidebar-header {
    padding: 15px 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid var(--gray-200);
    background: var(--white);
}

.sidebar-logo {
    max-width: 160px;
    height: auto;
}

.sidebar-nav {
    flex: 1;
    padding: 15px 0;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: var(--gray-600);
    text-decoration: none;
    transition: var(--transition);
}

.nav-item:hover {
    background: var(--gray-100);
    color: var(--primary);
}

.nav-item.active {
    background: var(--primary);
    color: var(--white);
}

.nav-item i {
    width: 24px;
    text-align: center;
}

.sidebar-footer {
    padding: 15px 20px;
    border-top: 1px solid var(--gray-200);
}

.btn-logout {
    width: 100%;
    background: transparent;
    color: var(--gray-600);
    border: 1px solid var(--gray-300);
}

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

/* Main Content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.main-header {
    height: var(--header-height);
    background: var(--white);
    padding: 0 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 50;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 24px;
    color: var(--gray-600);
    cursor: pointer;
}

.header-title h1 {
    font-size: 24px;
    color: var(--dark);
}

.header-title span {
    font-size: 14px;
    color: var(--gray-500);
}

.header-user {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--gray-600);
}

.header-user i {
    font-size: 32px;
    color: var(--primary);
}

/* Page Content */
.page-content {
    flex: 1;
    padding: 30px;
}

.page {
    display: none;
}

.page.active {
    display: block;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--white);
    padding: 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 20px;
}

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: var(--white);
}

.stat-icon.clients { background: linear-gradient(135deg, #e53935, #c62828); }
.stat-icon.products { background: linear-gradient(135deg, #5a5a5a, #424242); }
.stat-icon.orders { background: linear-gradient(135deg, #22c55e, #15803d); }
.stat-icon.revenue { background: linear-gradient(135deg, #e53935, #c62828); }

.stat-info h3 {
    font-size: 28px;
    color: var(--dark);
    margin-bottom: 4px;
}

.stat-info p {
    color: var(--gray-500);
    font-size: 14px;
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 20px;
}

.dashboard-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-header h3 {
    font-size: 16px;
    color: var(--dark);
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-header h3 i {
    color: var(--primary);
}

.card-body {
    padding: 20px;
}

.alerts-card .alert-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--gray-100);
    border-radius: var(--radius);
    margin-bottom: 10px;
}

.alerts-card .alert-item:last-child {
    margin-bottom: 0;
}

.alerts-card .alert-item i {
    color: var(--warning);
}

/* Page Header */
.page-header {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.page-header h2 {
    font-size: 20px;
    color: var(--dark);
}

.search-bar {
    display: flex;
    align-items: center;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 0 12px;
    flex: 1;
    max-width: 400px;
}

.search-bar i {
    color: var(--gray-400);
}

.search-bar input {
    border: none;
    padding: 10px 12px;
    font-size: 14px;
    width: 100%;
}

.search-bar input:focus {
    outline: none;
}

.filters {
    display: flex;
    align-items: center;
    gap: 12px;
}

.filters select,
.filters input[type="date"] {
    padding: 10px 12px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: 14px;
    background: var(--white);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--gray-600);
    cursor: pointer;
}

/* Tables */
.table-container {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
}

.table th {
    background: var(--gray-100);
    font-weight: 600;
    color: var(--gray-700);
    font-size: 13px;
    text-transform: uppercase;
}

.table td {
    font-size: 14px;
    color: var(--gray-700);
}

.table tbody tr:hover {
    background: var(--gray-50);
}

.table .actions {
    display: flex;
    gap: 8px;
}

/* Status Badges */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.badge-success { background: #dcfce7; color: #15803d; }
.badge-warning { background: #fef3c7; color: #b45309; }
.badge-danger { background: #fee2e2; color: #b91c1c; }
.badge-info { background: #dbeafe; color: #1d4ed8; }
.badge-secondary { background: var(--gray-200); color: var(--gray-700); }

/* Product Image */
.product-thumb {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: var(--radius);
    background: var(--gray-200);
}

/* Stock Status */
.stock-ok { color: var(--success); }
.stock-low { color: var(--warning); }
.stock-out { color: var(--danger); }

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--white);
    border-radius: var(--radius);
    width: 100%;
    max-width: 700px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    font-size: 18px;
    color: var(--dark);
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    color: var(--gray-400);
    cursor: pointer;
}

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

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--gray-200);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* Form Styles in Modal */
.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

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

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: var(--gray-700);
    font-size: 14px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 14px;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.form-group textarea {
    min-height: 100px;
    resize: vertical;
}

.form-section {
    margin-bottom: 24px;
}

.form-section h4 {
    font-size: 16px;
    color: var(--dark);
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--gray-200);
}

/* Toast */
.toast {
    position: fixed;
    bottom: 30px;
    right: 30px;
    padding: 16px 24px;
    border-radius: var(--radius);
    color: var(--white);
    font-weight: 500;
    z-index: 2000;
    transform: translateX(150%);
    transition: var(--transition);
}

.toast.active {
    transform: translateX(0);
}

.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.warning { background: var(--warning); }
.toast.info { background: var(--info); }

/* Reports */
.reports-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
}

.tab-btn {
    padding: 10px 20px;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 14px;
    transition: var(--transition);
}

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

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

.report-content {
    display: none;
}

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

.report-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.summary-item {
    background: var(--white);
    padding: 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    text-align: center;
}

.summary-item h4 {
    color: var(--gray-500);
    font-size: 14px;
    margin-bottom: 8px;
}

.summary-item span {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary);
}

.chart-container {
    background: var(--white);
    padding: 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    height: 400px;
}

/* Signature Canvas */
.signature-container {
    border: 2px dashed var(--gray-300);
    border-radius: var(--radius);
    padding: 10px;
    margin-bottom: 16px;
}

.signature-canvas {
    width: 100%;
    height: 200px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    cursor: crosshair;
}

/* Order Items */
.order-items-list {
    margin-top: 16px;
}

.order-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--gray-100);
    border-radius: var(--radius);
    margin-bottom: 8px;
}

.order-item-info {
    flex: 1;
}

.order-item-name {
    font-weight: 500;
}

.order-item-price {
    color: var(--gray-500);
    font-size: 14px;
}

.order-item-qty {
    display: flex;
    align-items: center;
    gap: 8px;
}

.order-item-qty input {
    width: 60px;
    text-align: center;
}

.order-item-remove {
    color: var(--danger);
    cursor: pointer;
}

/* Client Detail */
.client-detail-header {
    display: flex;
    align-items: flex-start;
    gap: 20px;
    margin-bottom: 24px;
}

.client-detail-info h2 {
    font-size: 24px;
    color: var(--dark);
    margin-bottom: 4px;
}

.client-detail-info p {
    color: var(--gray-500);
}

.client-stats {
    display: flex;
    gap: 20px;
    margin-top: 16px;
}

.client-stat {
    text-align: center;
    padding: 12px 20px;
    background: var(--gray-100);
    border-radius: var(--radius);
}

.client-stat strong {
    display: block;
    font-size: 20px;
    color: var(--primary);
}

.client-stat span {
    font-size: 12px;
    color: var(--gray-500);
}

.client-badges {
    display: flex;
    gap: 8px;
    margin: 8px 0;
}

.assignment-info {
    background: var(--gray-100);
    padding: 16px;
    border-radius: var(--radius);
    border-left: 4px solid var(--primary);
}

.assignment-info p {
    margin: 8px 0;
    color: var(--gray-700);
}

.assignment-info .form-row {
    display: flex;
    gap: 16px;
    align-items: flex-end;
}

.assignment-info .form-group {
    margin-bottom: 0;
}

.assignment-info select {
    background: var(--white);
}

/* Order Status Selects */
.status-select {
    padding: 6px 10px;
    border-radius: 6px;
    border: 2px solid transparent;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 130px;
}

.status-select:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.status-select.status-pending {
    background: #fff3e0;
    border-color: #ff9800;
    color: #e65100;
}

.status-select.status-confirmed {
    background: #e3f2fd;
    border-color: #2196f3;
    color: #1565c0;
}

.status-select.status-processing {
    background: #f3e5f5;
    border-color: #9c27b0;
    color: #7b1fa2;
}

.status-select.status-shipped {
    background: #e0f7fa;
    border-color: #00bcd4;
    color: #00838f;
}

.status-select.status-delivered {
    background: #e8f5e9;
    border-color: #4caf50;
    color: #2e7d32;
}

.status-select.status-cancelled {
    background: #ffebee;
    border-color: #f44336;
    color: #c62828;
}

.status-select.payment-pending {
    background: #fff3e0;
    border-color: #ff9800;
    color: #e65100;
}

.status-select.payment-partial {
    background: #fff8e1;
    border-color: #ffc107;
    color: #f57f17;
}

.status-select.payment-paid {
    background: #e8f5e9;
    border-color: #4caf50;
    color: #2e7d32;
}

.status-select.payment-refunded {
    background: #fce4ec;
    border-color: #e91e63;
    color: #c2185b;
}

/* Responsive */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
        box-shadow: 4px 0 20px rgba(0,0,0,0.3);
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .menu-toggle {
        display: block;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    /* Overlay when sidebar is open */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,0.5);
        z-index: 99;
    }

    .sidebar-overlay.active {
        display: block;
    }
}

@media (max-width: 768px) {
    .page-header {
        flex-direction: column;
        align-items: stretch;
    }

    .search-bar {
        max-width: none;
    }

    .filters {
        flex-wrap: wrap;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }

    .table-container {
        overflow-x: auto;
    }

    .modal-content {
        max-width: 100%;
        margin: 10px;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .main-header {
        padding: 0 16px;
    }

    .page-content {
        padding: 16px;
    }

    .header-title h1 {
        font-size: 18px;
    }
}

/* Price columns styling */
.price-telephonie {
    color: var(--info);
    font-weight: 500;
}

.price-alimentaire {
    color: var(--warning);
    font-weight: 500;
}

.price-minimum {
    color: var(--danger);
    font-weight: 500;
    font-size: 12px;
}

/* Products table - smaller font for more columns */
.table-products th,
.table-products td {
    font-size: 13px;
    padding: 8px 6px;
}

.table-products th {
    white-space: nowrap;
}

/* Alert warnings */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 14px;
}

.alert-warning {
    background: #fef3c7;
    border: 1px solid #f59e0b;
    color: #92400e;
}

.alert-warning i {
    margin-right: 8px;
    color: #f59e0b;
}

.alert-danger {
    background: #fee2e2;
    border: 1px solid #ef4444;
    color: #991b1b;
}

.alert-info {
    background: #e0f2fe;
    border: 1px solid #06b6d4;
    color: #0e7490;
}

/* Segment badges */
.badge-telephonie {
    background: var(--info);
}

.badge-alimentaire {
    background: var(--warning);
}

/* =====================================================
   MOBILE RESPONSIVE IMPROVEMENTS
   ===================================================== */

/* Mobile tables - card view for small screens */
@media (max-width: 768px) {
    /* Hide table headers on mobile */
    .table-mobile-cards thead {
        display: none;
    }

    .table-mobile-cards tbody tr {
        display: block;
        margin-bottom: 16px;
        background: var(--white);
        border-radius: var(--radius);
        box-shadow: var(--shadow);
        padding: 12px;
    }

    .table-mobile-cards tbody td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 8px 0;
        border: none;
        border-bottom: 1px solid var(--gray-100);
    }

    .table-mobile-cards tbody td:last-child {
        border-bottom: none;
    }

    .table-mobile-cards tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--gray-600);
        font-size: 12px;
        text-transform: uppercase;
    }

    /* Products table mobile */
    .table-products {
        font-size: 12px;
    }

    .table-products th,
    .table-products td {
        padding: 6px 4px;
        font-size: 11px;
    }

    .table-products .product-thumb {
        width: 30px;
        height: 30px;
    }

    /* Hide less important columns on mobile */
    .table-products th:nth-child(4),
    .table-products td:nth-child(4),
    .table-products th:nth-child(5),
    .table-products td:nth-child(5) {
        display: none;
    }

    /* Clients table mobile - hide some columns */
    #clientsPage .table th:nth-child(6),
    #clientsPage .table td:nth-child(6),
    #clientsPage .table th:nth-child(7),
    #clientsPage .table td:nth-child(7) {
        display: none;
    }

    /* Orders table mobile */
    #ordersPage .table th:nth-child(4),
    #ordersPage .table td:nth-child(4) {
        display: none;
    }

    /* Action buttons on mobile */
    .actions {
        display: flex;
        gap: 4px;
        flex-wrap: wrap;
        justify-content: flex-end;
    }

    .actions .btn-sm {
        padding: 6px 8px;
        font-size: 12px;
    }

    /* Page header mobile */
    .page-header {
        gap: 12px;
    }

    .page-header .btn {
        width: 100%;
        justify-content: center;
    }

    /* Filters on mobile */
    .filters {
        width: 100%;
        gap: 8px;
    }

    .filters select,
    .filters input {
        flex: 1;
        min-width: 120px;
    }

    /* Modal improvements for mobile */
    .modal-content {
        width: 95%;
        max-height: 90vh;
        margin: 5vh auto;
    }

    .modal-body {
        padding: 16px;
    }

    .modal-footer {
        flex-direction: column;
        gap: 8px;
    }

    .modal-footer .btn {
        width: 100%;
    }

    /* Form improvements for mobile */
    .form-row {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 12px;
    }

    .form-section h4 {
        font-size: 14px;
    }

    /* Dashboard cards on mobile */
    .stat-card {
        padding: 16px;
    }

    .stat-card .stat-icon {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }

    .stat-info h3 {
        font-size: 20px;
    }

    .stat-info p {
        font-size: 12px;
    }

    /* Dashboard grid mobile */
    .dashboard-card {
        padding: 12px;
    }

    .card-header h3 {
        font-size: 14px;
    }

    /* Order items on mobile */
    .order-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .order-item-qty {
        width: 100%;
        justify-content: space-between;
    }

    /* Reports on mobile */
    .reports-tabs {
        flex-wrap: wrap;
    }

    .tab-btn {
        flex: 1;
        min-width: 80px;
        text-align: center;
        padding: 8px 12px;
        font-size: 12px;
    }

    .report-summary {
        grid-template-columns: 1fr;
    }

    .chart-container {
        height: 250px;
    }

    /* Client stats on mobile */
    .client-stats {
        flex-wrap: wrap;
    }

    .client-stat {
        flex: 1;
        min-width: 80px;
        padding: 8px 12px;
    }

    /* Header on mobile */
    .main-header {
        height: auto;
        min-height: 60px;
        padding: 10px 16px;
    }

    .header-title h1 {
        font-size: 16px;
    }

    #headerDate {
        display: none;
    }

    .header-user span {
        display: none;
    }
}

/* Extra small screens (phones in portrait) */
@media (max-width: 400px) {
    .stats-grid {
        gap: 8px;
    }

    .stat-card {
        padding: 12px;
    }

    .page-content {
        padding: 12px;
    }

    .table th,
    .table td {
        padding: 6px 4px;
        font-size: 11px;
    }

    .badge {
        padding: 2px 6px;
        font-size: 10px;
    }

    .btn-sm {
        padding: 4px 6px;
        font-size: 11px;
    }

    /* Hide more columns on very small screens */
    .table-products th:nth-child(3),
    .table-products td:nth-child(3) {
        max-width: 80px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    .btn {
        min-height: 44px;
        min-width: 44px;
    }

    .nav-item {
        padding: 14px 20px;
    }

    .table td,
    .table th {
        padding: 12px 8px;
    }

    select,
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="date"],
    input[type="tel"],
    textarea {
        min-height: 44px;
    }
}

/* Landscape phone orientation */
@media (max-height: 500px) and (orientation: landscape) {
    .modal-content {
        max-height: 95vh;
    }

    .modal-body {
        max-height: 60vh;
    }

    .login-container {
        padding: 20px;
    }

    .login-logo {
        margin-bottom: 15px;
    }

    .login-logo i {
        font-size: 32px;
    }
}

/* Login page mobile improvements */
@media (max-width: 480px) {
    .login-container {
        padding: 24px;
        margin: 10px;
    }

    .login-logo i {
        font-size: 40px;
    }

    .login-logo h1 {
        font-size: 24px;
    }

    .login-form input {
        padding: 14px;
        font-size: 16px;
    }

    .login-form .btn {
        padding: 14px;
        font-size: 16px;
    }
}

/* Safe area insets for notched phones */
@supports (padding: max(0px)) {
    .main-app {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }

    .sidebar {
        padding-bottom: env(safe-area-inset-bottom);
    }

    .modal-content {
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* Prevent text selection on buttons for better mobile UX */
.btn, .nav-item, .tab-btn {
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

/* Smooth scrolling for iOS */
.table-container,
.modal-body,
.sidebar-nav {
    -webkit-overflow-scrolling: touch;
}

/* =====================================================
   MOBILE CARDS VIEW
   ===================================================== */

.cards-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 0;
}

/* Product Cards */
.product-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 12px;
}

.product-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.product-sku {
    font-size: 12px;
    font-weight: 600;
    color: var(--primary);
    background: var(--gray-100);
    padding: 2px 8px;
    border-radius: 4px;
}

.product-stock {
    font-size: 11px;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 4px;
}

.product-stock.stock-ok {
    background: #dcfce7;
    color: #166534;
}

.product-stock.stock-low {
    background: #fef3c7;
    color: #92400e;
}

.product-stock.stock-out {
    background: #fee2e2;
    color: #991b1b;
}

.product-card-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--dark);
    margin-bottom: 10px;
    line-height: 1.3;
}

.product-card-prices {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.price-item {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
}

.price-label {
    color: var(--gray-500);
    font-size: 11px;
}

.product-card-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    padding-top: 10px;
    border-top: 1px solid var(--gray-100);
}

/* Client Cards */
.client-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 12px;
}

.client-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.client-code {
    font-size: 12px;
    font-weight: 600;
    color: var(--primary);
    background: var(--gray-100);
    padding: 2px 8px;
    border-radius: 4px;
}

.client-card-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--dark);
    margin-bottom: 8px;
}

.client-card-info {
    display: flex;
    gap: 16px;
    font-size: 12px;
    color: var(--gray-500);
    margin-bottom: 12px;
}

.client-card-info i {
    margin-right: 4px;
    color: var(--gray-400);
}

.client-card-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    padding-top: 10px;
    border-top: 1px solid var(--gray-100);
}

/* No data message */
.no-data {
    text-align: center;
    padding: 40px 20px;
    color: var(--gray-500);
    font-size: 14px;
}


/* QR Code Section */
.qr-code-section {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 20px;
    background: linear-gradient(135deg, var(--gray-100) 0%, var(--white) 100%);
    border-radius: var(--radius);
    border: 1px solid var(--gray-200);
}

.qr-code-container {
    background: var(--white);
    padding: 12px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    justify-content: center;
}

.qr-code-container img,
.qr-code-container canvas {
    display: block !important;
}

.qr-code-info {
    flex: 1;
}

.qr-code-info .qr-sku {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 4px;
    font-family: monospace;
}

.qr-code-info .qr-name {
    font-size: 14px;
    color: var(--gray-600);
    margin-bottom: 16px;
    line-height: 1.4;
}

.qr-code-info .btn {
    margin-top: 8px;
}

/* Responsive QR Code */
@media (max-width: 600px) {
    .qr-code-section {
        flex-direction: column;
        text-align: center;
    }

    .qr-code-info {
        width: 100%;
    }

    .qr-code-info .btn {
        width: 100%;
    }
}

/* =====================================================
   CALENDAR / AGENDA VIEW - CLEAN DESIGN
   ===================================================== */

.view-toggle {
    display: flex;
    gap: 0;
    background: var(--gray-200);
    padding: 3px;
    border-radius: 8px;
}

.view-toggle .btn {
    border: none;
    background: transparent;
    color: var(--gray-600);
    padding: 8px 20px;
    border-radius: 6px;
    transition: var(--transition);
    font-weight: 500;
}

.view-toggle .btn.active {
    background: var(--white);
    color: var(--primary);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.view-toggle .btn:hover:not(.active) {
    color: var(--gray-800);
}

/* Calendar Container */
#tourneeCalendarView {
    display: flex;
    gap: 20px;
}

/* Calendar Filters - Left Panel */
.calendar-filters {
    width: 220px;
    flex-shrink: 0;
    background: var(--white);
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    padding: 20px;
    height: fit-content;
}

.filter-label {
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 15px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-label i {
    color: var(--primary);
}

.commercial-checkboxes {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.commercial-checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid transparent;
}

.commercial-checkbox:hover {
    background: var(--gray-100);
}

.commercial-checkbox.active {
    background: #f8f9fa;
    border-color: var(--gray-300);
}

.commercial-checkbox input {
    display: none;
}

.commercial-color-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    flex-shrink: 0;
}

.commercial-checkbox-name {
    flex: 1;
    font-size: 13px;
    color: var(--gray-700);
}

.commercial-checkbox-count {
    font-size: 11px;
    color: var(--gray-500);
    background: var(--gray-200);
    padding: 2px 8px;
    border-radius: 10px;
}

/* Calendar Main Container */
.calendar-container {
    flex: 1;
    background: var(--white);
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    overflow: hidden;
}

/* Calendar Header - Clean */
.calendar-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    padding: 18px 25px;
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
}

.calendar-header h3 {
    font-size: 1.3rem;
    font-weight: 600;
    margin: 0;
    color: var(--gray-800);
    text-transform: capitalize;
    min-width: 180px;
    text-align: center;
}

.calendar-header .btn {
    background: var(--gray-100);
    border: none;
    color: var(--gray-600);
    padding: 8px 12px;
    border-radius: 6px;
}

.calendar-header .btn:hover {
    background: var(--gray-200);
    color: var(--gray-800);
}

.btn-outline {
    background: transparent !important;
    border: 1px solid var(--gray-300) !important;
}

/* Calendar Grid - Clean */
.calendar-grid {
    padding: 0;
}

.calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    background: var(--gray-100);
    border-bottom: 1px solid var(--gray-200);
}

.calendar-weekday {
    padding: 12px 8px;
    text-align: center;
    font-weight: 600;
    font-size: 11px;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.calendar-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
}

.calendar-day {
    min-height: 100px;
    border-right: 1px solid var(--gray-100);
    border-bottom: 1px solid var(--gray-100);
    padding: 8px;
    background: var(--white);
    transition: background 0.2s;
    position: relative;
}

.calendar-day:nth-child(7n) {
    border-right: none;
}

.calendar-day:hover {
    background: #fafafa;
}

.calendar-day.other-month {
    background: #f5f5f5;
}

.calendar-day.other-month .day-number {
    color: var(--gray-400);
}

.calendar-day.today {
    background: #fffde7;
}

.calendar-day.today .day-number {
    background: var(--primary);
    color: white;
}

.day-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    font-weight: 500;
    font-size: 13px;
    color: var(--gray-700);
    margin-bottom: 6px;
}

.day-events {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

/* Event Pill - Simple Design with Commercial Color */
.calendar-event {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 8px;
    border-radius: 6px;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s;
    color: white;
    position: relative;
}

.calendar-event:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(0,0,0,0.2);
}

.event-status-icon {
    font-size: 9px;
    opacity: 0.9;
}

.event-time {
    font-weight: 600;
    font-size: 10px;
}

.event-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 10px;
    opacity: 0.95;
}

/* Cancelled events */
.calendar-event.status-cancelled {
    opacity: 0.5;
}
.calendar-event.status-cancelled .event-name {
    text-decoration: line-through;
}

/* More events */
.more-events {
    font-size: 10px;
    color: var(--primary);
    text-align: center;
    padding: 4px;
    cursor: pointer;
    font-weight: 500;
    border-radius: 4px;
    transition: background 0.2s;
}

.more-events:hover {
    background: var(--gray-100);
}

/* Commercial colors */
.commercial-color-0 { background-color: #e53935 !important; }
.commercial-color-1 { background-color: #1976d2 !important; }
.commercial-color-2 { background-color: #388e3c !important; }
.commercial-color-3 { background-color: #7b1fa2 !important; }
.commercial-color-4 { background-color: #f57c00 !important; }
.commercial-color-5 { background-color: #00796b !important; }
.commercial-color-6 { background-color: #5d4037 !important; }
.commercial-color-7 { background-color: #c2185b !important; }

/* Calendar responsive */
@media (max-width: 1100px) {
    #tourneeCalendarView {
        flex-direction: column;
    }

    .calendar-filters {
        width: 100%;
        margin-bottom: 0;
    }

    .commercial-checkboxes {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 6px;
    }

    .commercial-checkbox {
        padding: 8px 12px;
    }
}

@media (max-width: 900px) {
    .calendar-day {
        min-height: 85px;
        padding: 6px;
    }

    .event-name {
        display: none;
    }

    .calendar-event {
        padding: 4px 6px;
    }
}

@media (max-width: 768px) {
    .calendar-header {
        flex-wrap: wrap;
        gap: 10px;
        padding: 15px;
    }

    .calendar-header h3 {
        font-size: 1.1rem;
        min-width: 150px;
    }

    .calendar-day {
        min-height: 70px;
        padding: 4px;
    }

    .day-number {
        width: 22px;
        height: 22px;
        font-size: 11px;
        margin-bottom: 4px;
    }

    .calendar-weekday {
        padding: 8px 4px;
        font-size: 10px;
    }

    .calendar-event {
        padding: 3px 5px;
    }

    .event-time {
        font-size: 9px;
    }

    .commercial-checkbox {
        padding: 6px 10px;
    }

    .commercial-checkbox-name {
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .view-toggle {
        width: 100%;
    }

    .view-toggle .btn {
        flex: 1;
        padding: 10px;
    }

    .calendar-day {
        min-height: 55px;
    }

    .day-events {
        gap: 2px;
    }

    .calendar-event {
        padding: 2px 4px;
        gap: 3px;
    }

    .event-status-icon {
        font-size: 8px;
    }

    .event-time {
        font-size: 8px;
    }

    .commercial-checkboxes {
        gap: 4px;
    }

    .commercial-checkbox {
        padding: 5px 8px;
    }

    .commercial-checkbox-count {
        display: none;
    }
}
