/* =================================
   Variables & Reset
   ================================= */
:root {
    /* Palette principale simplifiée (3-5 couleurs) */
    --primary: #000000;
    --primary-50: #eef2ff;
    --primary-hover: #3B82F6;
    --success: #22c55e;
    --warning: #f97316;
    --danger: #ef4444;

    /* Gris simplifiés (réduit à l'essentiel) */
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-900: #111827;
    --white: #ffffff;

    /* Aliases sémantiques pour faciliter l'usage */
    --text-primary: var(--gray-900);
    --text-secondary: var(--gray-600);
    --border-color: var(--gray-200);
    --bg-base: var(--white);
    --bg-subtle: var(--gray-50);

    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xlg: 25px;

    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 4px 20px 0 rgba(0, 0, 0, 0.075);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
}

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

body {
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 13px;
    line-height: 1.6;
    color: var(--gray-700);
    background: white;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* =================================
   Typography
   ================================= */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    color: var(--gray-900);
    line-height: 1.2;
    margin-bottom: 0.65rem;
}

h1 { font-size: 1.5rem; font-weight: 700; }   /* 24px - further reduced */
h2 { font-size: 1.2rem; font-weight: 600; }  /* 19.2px - further reduced */
h3 { font-size: 1rem; }                      /* 16px - further reduced */
h4 { font-size: 0.9rem; }                    /* 14.4px - further reduced */
h5 { font-size: 0.8rem; }                    /* 12.8px - further reduced */

.lead {
    font-size: 1rem;
    font-weight: 400;
    color: var(--gray-600);
}

/* =================================
   Sidebar Navigation
   ================================= */
body.has-sidebar {
    margin: 0;
    padding: 0;
}

.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    width: 220px;
    background: var(--white);
    border-right: 1px solid var(--gray-200);
    display: flex;
    flex-direction: column;
    transition: width 0.3s ease, transform 0.3s ease;
    z-index: 1000;
    overflow: visible;
}

.sidebar.collapsed {
    width: 60px;
}

.sidebar-header {
    padding: 0.5rem 1.4rem 0.5rem 1.4rem;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 50px;
    overflow: hidden;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: var(--gray-900);
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -2px;
    text-transform: uppercase;
    transition: all 0.3s;
}

.sidebar-brand svg {
    min-width: 24px;
}

.sidebar-brand-text {
    white-space: nowrap;
    transition: opacity 0.3s;
}

.sidebar.collapsed .sidebar-brand-text {
    opacity: 0;
    width: 0;
}

.sidebar-toggle-btn {
    position: absolute;
    right: -13px;
    top: 37px;
    background: white;
    border: 1px solid #e5e7eb;
    color: #6b7280;
    cursor: pointer;
    padding: 0.1rem;
    border-radius: 25px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: auto;
    height: auto;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    z-index: 1001;
}

.sidebar-toggle-btn:hover {
    background: #f9fafb;
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.sidebar.collapsed .sidebar-toggle-btn:hover {
    background: #f9fafb;
}

.sidebar.collapsed .sidebar-toggle-btn:hover svg {
    stroke: #6b7280;
}

.sidebar-toggle-btn:active {
    transform: scale(0.95);
}

.sidebar-toggle-btn svg {
    pointer-events: none;
    flex-shrink: 0;
    width: 20px;
    height: 20px;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.3rem 1.4rem;
    color: var(--gray-700);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.7rem;
    transition: all 0.2s;
    position: relative;
}

.sidebar-link:hover {
    background: var(--gray-50);
    color: var(--primary);
}

.sidebar-link.active {
    background: var(--gray-50);
    color: var(--primary);
}

.sidebar-link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--primary);
}

.sidebar-link i {
    font-size: 20px;
}

.sidebar-link span {
    white-space: nowrap;
    transition: opacity 0.3s;
}

.sidebar.collapsed .sidebar-link span {
    opacity: 0;
    width: 0;
}

.sidebar.collapsed .sidebar-link .notif-badge {
    opacity: 1;
    width: 0;
}

/* Trial badge for modules in trial period */
.trial-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--warning);
    color: var(--white);
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    margin-left: auto;
    white-space: nowrap;
    min-width: 28px;
}

.sidebar.collapsed .trial-badge {
    opacity: 0;
    width: 0;
    overflow: hidden;
}

.sidebar-link.admin-link {
    background: var(--warning);
    color: var(--white);
    margin: 0.5rem 1rem;
    border-radius: var(--radius-md);
    padding: 0.75rem 1rem;
}

.sidebar-link.admin-link:hover {
    background: #ea580c;
}

.sidebar-footer {
    border-top: 1px solid var(--gray-200);
    overflow: hidden;
}

.sidebar-user {
    padding: 0.75rem 1.5rem;
}

.sidebar-user-info {
    transition: opacity 0.3s;
}

.sidebar.collapsed .sidebar-user-info {
    opacity: 0;
    width: 0;
    height: 0;
    overflow: hidden;
}

/* Offline controls - Collapsed State */
.sidebar.collapsed .offline-status-section {
    flex-direction: column;
    padding: 0.5rem 0 !important;
    gap: 0.5rem !important;
    justify-content: center !important;
    align-items: center !important;
}

.sidebar.collapsed .offline-status-info {
    display: none !important;
}

.sidebar.collapsed .offline-sync-btn {
    padding: 0 !important;
    width: 33px;
    height: 33px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

.sidebar.collapsed .offline-sync-btn i {
    font-size: 1rem;
}

.sidebar.collapsed .offline-sync-btn .sidebar-brand-text {
    display: none;
}

.sidebar.collapsed .offline-toggle-section {
    flex-direction: column;
    padding: 0.5rem 0 !important;
    gap: 0 !important;
    justify-content: center !important;
    align-items: center !important;
}

.sidebar.collapsed .offline-toggle-label {
    display: none !important;
}

.sidebar.collapsed .offline-toggle {
    width: 33px;
    height: 20px;
}

.sidebar.collapsed .offline-toggle-slider:before {
    height: 14px;
    width: 14px;
}

.sidebar.collapsed .offline-toggle input:checked + .offline-toggle-slider:before {
    transform: translateX(13px);
}

.sidebar-user-name {
    font-weight: 600;
    font-size: 0.7rem;
    color: var(--gray-900);
    white-space: nowrap;
}

.sidebar-user-plan {
    font-size: 0.8rem;
    color: var(--gray-500);
    margin-top: 0.25rem;
}

.main-content {
    margin-left: 220px;
    transition: margin-left 0.3s ease;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.sidebar.collapsed + .main-content {
    margin-left: 60px;
}

.content-wrapper {
    flex: 1;
    padding: 1.125rem 1.35rem;
    max-width: 100%;
    width: 100%;
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-220px);
    }

    .sidebar.collapsed {
        transform: translateX(-60px);
    }

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

/* =================================
   Container & Layout
   ================================= */
.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 1.35rem;
}

.container-wide {
    max-width: 1150px;
}

.container-narrow {
    max-width: 680px;
}

main {
    min-height: calc(100vh - 140px);
    padding: 1.75rem 0;
}

body:not(.has-sidebar) main {
    padding: 1.75rem 0;
}

/* =================================
   Buttons
   ================================= */
.btn {
    display: inline-block;
    padding: 0.8rem 1.25rem;
    line-height: 1.2;
    font-size: 0.75rem;
    font-weight: 500;
    text-align: center;
    text-decoration: none;
    border: none;
    border-radius: var(--radius-xlg);
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'Poppins', sans-serif;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--primary);
    color: var(--white);
    border: 2px solid var(--primary);
}

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

.btn-secondary {
    background: var(--gray-100);
    color: var(--gray-700);
    border: 2px solid var(--gray-100);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--gray-200);
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--gray-300);
    color: var(--gray-700);
}

.btn-outline:hover:not(:disabled) {
    border-color: var(--primary-hover);
    color: var(--primary);
}

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

.btn-success {
    background: var(--success);
    color: var(--white);
    border: 2px solid var(--success);
}

.btn-success:hover:not(:disabled) {
    background: #059669;
    border-color: #059669;
}

.btn-warning {
    background: var(--warning);
    color: var(--white);
    border: 2px solid var(--warning);
}

.btn-warning:hover:not(:disabled) {
    background: #ea580c;
    border-color: #ea580c;
}

.btn-danger {
    background: var(--danger);
    color: var(--white);
    border: 2px solid var(--danger);
}

.btn-danger:hover:not(:disabled) {
    background: #dc2626;
    border-color: #dc2626;
}

.btn-sm {
    padding: 0.4rem 0.875rem;
    font-size: 0.8rem;
}

.btn-lg {
    padding: 1rem 1.75rem;
    font-size: 1rem;
    border-radius: 30px;
}

.btn-block {
    display: block;
    width: 100%;
}

/* =================================
   Cards
   ================================= */
.card {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
    padding: 1.125rem 1.35rem;
}

.card-clickable {
    transition: all 0.3s;
}

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

.card-header {
    padding: 1.125rem;
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.card-body {
    padding: 1.125rem;
}

.card-footer {
    padding: 1.125rem;
    background: var(--gray-50);
    border-top: 1px solid var(--gray-200);
}

/* =================================
   Forms
   ================================= */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    margin-bottom: 0.4rem;
    font-weight: 500;
    color: var(--gray-700);
    font-size: 0.9rem;
}

.form-control, .form-select {
    width: 100%;
    padding: 0.625rem 0.875rem;
    font-size: 0.7rem;
    font-family: 'Poppins', sans-serif;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-xlg);
    background: var(--white);
    transition: all 0.2s;
}

.form-control:focus, .form-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

.form-control:disabled {
    background: var(--gray-100);
    cursor: not-allowed;
}

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

.form-text {
    display: block;
    margin-top: 0.5rem;
    font-size: 0.85rem;
    color: var(--gray-500);
}

/* =================================
   Alerts
   ================================= */
.alert {
    padding: 1rem 1.25rem;
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
    border-left: 4px solid;
    /*display: flex;*/
    align-items: start;
    gap: 0.75rem;
}

.alert-success {
    background: rgba(16, 185, 129, 0.1);
    border-color: var(--success);
    color: #065f46;
}

.alert-info {
    background: var(--gray-100);
    border-color: var(--primary);
    color: #3730a3;
}

.alert-warning {
    background: rgba(245, 158, 11, 0.1);
    border-color: var(--warning);
    color: #92400e;
}

.alert-danger {
    background: rgba(239, 68, 68, 0.1);
    border-color: var(--danger);
    color: #991b1b;
}

/* Flash messages animations */
@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideOutRight {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

.flash-message.removing {
    animation: slideOutRight 0.3s ease forwards;
}

/* Responsive flash messages on mobile */
@media (max-width: 768px) {
    #flashMessagesContainer {
        transform: translateX(0);
        top: 4.5rem !important;
        right: 0.5rem !important;
        left: 0.5rem !important;
        width: calc(100% - 1rem) !important;
        max-width: none !important;
    }
}

/* =================================
   Tables
   ================================= */
.table-container {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--white);
}

thead {
    background: var(--gray-50);
}

th {
    padding: 1rem 1.5rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gray-600);
    border-bottom: 2px solid var(--gray-200);
}

td {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--gray-200);
}

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

/* =================================
   Badges
   ================================= */
.badge {
    display: inline-block;
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.badge-primary { background: var(--primary); color: var(--white); }
.badge-success { background: var(--success); color: var(--white); }
.badge-warning { background: var(--warning); color: var(--white); }
.badge-danger { background: var(--danger); color: var(--white); }
.badge-secondary { background: var(--gray-200); color: var(--gray-700); }

/* =================================
   Grid System
   ================================= */
.row {
    display: flex;
    flex-wrap: wrap;
    margin: 0 -1rem;
}

[class*="col-"] {
    padding: 0 1rem;
    margin-bottom: 2rem;
}

.col-md-3 { width: 25%; }
.col-md-4 { width: 33.333%; }
.col-md-6 { width: 50%; }
.col-md-8 { width: 66.666%; }
.col-md-12 { width: 100%; }

@media (max-width: 768px) {
    [class*="col-"] { width: 100%; }
}

/* =================================
   Utilities
   ================================= */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--gray-500); }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }
.mt-5 { margin-top: 3rem; }

.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }
.mb-5 { margin-bottom: 3rem; }

.d-flex { display: flex; }
.flex-column { flex-direction: column; }
.align-items-center { align-items: center; }
.justify-content-between { justify-content: space-between; }
.justify-content-center { justify-content: center; }
.gap-2 { gap: 1rem; }
.gap-3 { gap: 1.5rem; }

/* =================================
   Footer
   ================================= */
footer {
    background: var(--white);
    padding: 0.2rem 0;
    margin-top: auto;
}

.footer-text {
    text-align: center;
    color: var(--gray-500);
    font-size: 0.6rem;
}

/* =================================
   Animations
   ================================= */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in {
    animation: fadeIn 0.5s ease-out;
}

/* =================================
   Model Cards (Specific)
   ================================= */
.model-card {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid var(--gray-200);
}

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

.model-preview {
    height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.model-preview.facture {
    background: var(--primary);
}

.model-preview.devis {
    background: var(--warning);
}

.model-preview.contrat {
    background: var(--success);
}

.model-preview-icon {
    font-size: 4rem;
    z-index: 2;
}

.model-type-badge {
    position: absolute;
    top: 1rem;
    right: 1rem;
    z-index: 3;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 0.4rem 0.8rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.75rem;
    color: var(--gray-700);
}

.premium-badge {
    position: absolute;
    top: 1rem;
    left: 1rem;
    z-index: 3;
}

/* =================================
   Stats Cards
   ================================= */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: black;
    border-radius: 8px;
    padding: 1rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    border: 1px solid #e5e7eb;
    position: relative;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 100px;
    height: 100px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    transform: translate(30%, -30%);
}

.stat-value {
    font-size: 1.35rem;
    font-weight: 700;
    color: white;
    margin-bottom: 0.25rem;
}

.stat-label {
    color: white;
    font-size: 0.8rem;
    font-weight: 500;
}

.stats-card h5 {
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.875rem;
    margin-bottom: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stats-card .display-4 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
}

/* =================================
   RESPONSIVE DESIGN
   ================================= */

/* Desktop 24" et plus (> 1440px) - Tailles confortables */
@media (min-width: 1441px) {
    /* Augmentation pour grands écrans */
    body {
        font-size: 15px;
    }

    h1 { font-size: 2rem; }      /* 32px */
    h2 { font-size: 1.625rem; }  /* 26px */
    h3 { font-size: 1.375rem; }  /* 22px */
    h4 { font-size: 1.125rem; }  /* 18px */
    h5 { font-size: 1rem; }      /* 16px */

    .sidebar {
        width: 250px;
    }

    .sidebar.collapsed {
        width: 70px;
    }

    .main-content {
        margin-left: 250px;
    }

    .sidebar.collapsed + .main-content {
        margin-left: 70px;
    }

    .container {
        max-width: 1200px;
        padding: 2rem;
    }

    .container-wide {
        max-width: 1400px;
    }

    .content-wrapper {
        padding: 1.5rem 2rem;
    }

    main {
        padding: 2.5rem 0;
    }

    .card {
        padding: 1.5rem 2rem;
    }

    .card-header,
    .card-body,
    .card-footer {
        padding: 1.5rem;
    }

    .btn {
        padding: 0.7rem 1.5rem;
        font-size: 0.95rem;
    }

    .form-control, .form-select {
        padding: 0.75rem 1rem;
        font-size: 0.95rem;
    }
}

/* 13" Display Optimization (1280px - 1440px) - Compact */
@media (min-width: 1280px) and (max-width: 1440px) {
    /* Les valeurs par défaut sont déjà optimisées pour 13" */
    /* Aucun ajustement supplémentaire nécessaire */
}

/* Tablets and below (< 992px) */
@media (max-width: 991.98px) {
    /* Typography adjustments */
    h1 { font-size: 2rem; }
    h2 { font-size: 1.75rem; }
    h3 { font-size: 1.25rem; }
    
    .lead { font-size: 1rem; }
    
    /* Page header responsive */
    .page-header {
        padding: 1.5rem 1rem;
    }
    
    .page-header h1 {
        font-size: 1.75rem;
    }
    
    /* Sidebar becomes overlay on mobile/tablet */
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.mobile-open {
        transform: translateX(0);
    }
    
    /* Main content full width on mobile */
    .main-content {
        margin-left: 0 !important;
        padding: 1rem;
    }
    
    body.has-sidebar .main-content {
        margin-left: 0 !important;
    }
    
    /* Cards grid responsive */
    .card-grid,
    .stats-grid,
    .model-selection {
        grid-template-columns: 1fr !important;
        gap: 1rem;
    }
    
    /* Table responsive */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    table:not(.table-mobile-cards):not(.stats-table) {
        min-width: 800px;
    }
    
    /* Button groups stack vertically */
    .btn-group {
        flex-direction: column !important;
        gap: 0.5rem;
    }
    
    .btn-group .btn {
        width: 100%;
    }
    
    /* Form grids to single column */
    .form-grid {
        grid-template-columns: 1fr !important;
    }
}

/* Mobile only (< 768px) */
@media (max-width: 767.98px) {
    /* Even smaller typography */
    h1 { font-size: 1.5rem; }
    h2 { font-size: 1.35rem; }

    /* Hide sidebar by default on mobile - COMPACT MODE (icons only) */
    .sidebar {
        width: 70px;
        transform: translateX(-100%);
        z-index: 1002; /* Au-dessus de l'overlay */
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
    }

    .sidebar.mobile-open {
        transform: translateX(0);
    }

    /* Hide text labels on mobile - icons only */
    .sidebar .sidebar-link span:not(.trial-badge),
    .sidebar .sidebar-brand-text,
    .sidebar .sidebar-user-name,
    .sidebar .sidebar-user-email,
    .sidebar .logout-text {
        display: none !important;
    }

    /* Center icons in compact mobile sidebar */
    .sidebar .sidebar-link {
        justify-content: center;
    }

    .sidebar .sidebar-link svg {
        margin: 0;
    }

    /* Adjust header for compact mode */
    .sidebar .sidebar-header {
        padding: 1rem 0;
        justify-content: center;
    }

    .sidebar .sidebar-brand {
        justify-content: center;
        padding: 0;
    }

    .sidebar .sidebar-brand img {
        margin: 0 !important;
    }

    /* Trial badge positioning in compact mode */
    .sidebar .trial-badge {
        position: absolute;
        top: 0.5rem;
        right: 0.5rem;
        font-size: 0.65rem;
        padding: 2px 4px;
        min-width: 24px;
    }

    /* Notification badge positioning in compact mode */
    .sidebar .sidebar-link [style*="position: absolute"] {
        left: auto !important;
        right: 0.5rem !important;
        top: 0.5rem !important;
    }

    /* Sidebar footer in compact mobile mode */
    .sidebar .sidebar-footer {
        padding: 0.75rem 0;
        margin-bottom: 1.5rem;
    }

    .sidebar.collapsed .offline-toggle-label {
        display: none!important;
    }

    .sidebar .sidebar-user {
        display: none;
    }

    .sidebar .sidebar-user-info {
        display: none !important;
    }

    /* Offline status section compact */
    .sidebar .offline-status-section {
        flex-direction: column;
        padding: 0.5rem 0 !important;
        gap: 0.5rem !important;
        justify-content: center !important;
        align-items: center !important;
    }

    .sidebar .offline-status-label {
        display: none !important;
    }

    /* Subscription link compact */
    .sidebar .subscription-link-sidebar {
        padding: 0.5rem 0 !important;
        justify-content: center !important;
    }

    .sidebar .subscription-link-sidebar span {
        display: none !important;
    }

    /* Hide desktop sidebar toggle button on mobile */
    .sidebar-toggle-btn {
        display: none !important;
    }

    /* Mobile menu toggle button - Round design */
    .mobile-menu-toggle {
        display: flex !important;
        align-items: center;
        justify-content: center;
        position: fixed;
        top: 1rem;
        left: 1rem;
        z-index: 1003;
        background: white;
        border: 1px solid #e5e7eb;
        border-radius: 50%;
        width: 48px;
        height: 48px;
        cursor: pointer;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .mobile-menu-toggle svg {
        color: var(--primary);
        transition: all 0.3s ease;
    }

    .mobile-menu-toggle:hover {
        background: #f9fafb;
        transform: scale(1.05);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    }

    .mobile-menu-toggle:active {
        transform: scale(0.95);
    }

    /* Hide button when menu is open */
    .mobile-menu-toggle.menu-open {
        opacity: 0;
        pointer-events: none;
        transform: translateX(-20px);
    }

    /* Mobile overlay */
    .mobile-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1001;
        backdrop-filter: blur(2px);
    }
    
    /* Main content padding */
    .main-content {
        padding: 0.75rem;
        padding-top: 4rem; /* Space for mobile menu toggle */
    }
    
    /* Cards full width */
    .card {
        margin-bottom: 1rem;
    }
    
    /* Stats cards single column */
    .stats-grid {
        grid-template-columns: 1fr !important;
    }
    
    /* Page header actions stack */
    .page-header > div {
        flex-direction: column !important;
        gap: 1rem;
        align-items: flex-start !important;
    }
    
    .page-header .btn-group {
        width: 100%;
    }
    
    /* Table to cards on mobile */
    .card .table-mobile-cards,
    .table-mobile-cards {
        display: block;
        width: 100% !important;
        min-width: auto !important;
        table-layout: auto !important;
    }

    /* Ensure card body doesn't add extra padding that causes overflow */
    .card-body {
        overflow-x: hidden;
    }

    /* Add background to ALL containers with mobile cards for better contrast */
    .card-body:has(.table-mobile-cards),
    .table-responsive:has(.table-mobile-cards),
    .products-table:has(.table-mobile-cards),
    .products-table,
    .expense-table:has(.table-mobile-cards),
    div:has(> .table-mobile-cards) {
        background: var(--gray-50) !important;
        box-shadow: unset !important;
        padding: 1rem 0 !important;
    }

    /* Force background on card containers */
    .card:has(.table-mobile-cards),
    .card:has(.table-mobile-cards) .card-body,
    .table-responsive:has(.table-mobile-cards) {
        background: var(--gray-50) !important;
        padding: 1rem 0 !important;
    }

    /* Remove extra shadow from containers in mobile mode */
    div:has(.table-mobile-cards) {
        box-shadow: none !important;
    }

    /* Hide pagination text on mobile, keep only arrows */
    .pagination-text {
        display: none;
    }

    .table-mobile-cards thead {
        display: none;
    }

    .table-mobile-cards tbody,
    .table-mobile-cards tr {
        display: block;
        width: 100%;
    }

    .table-mobile-cards tbody {
        background: var(--gray-50) !important;
    }

    .table-mobile-cards tr {
        background: var(--white);
        border-radius: var(--radius-md);
        padding: 1rem;
        margin-bottom: 1rem;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
        border: 1px solid var(--gray-200);
        width: 100% !important;
        max-width: 100%;
        overflow: hidden;
    }

    .table-mobile-cards th,
    .table-mobile-cards td {
        width: auto !important;
        min-width: auto !important;
        max-width: 100% !important;
    }
    
    .table-mobile-cards td {
        display: block;
        padding: 0.2rem 0;
        border: none;
        border-bottom: 1px solid var(--gray-100);
        word-wrap: break-word;
        overflow-wrap: break-word;
        white-space: normal !important;
        overflow: visible !important;
        text-overflow: clip !important;
    }

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

    .table-mobile-cards td[data-label]::before {
        content: attr(data-label) !important;
        display: block !important;
        font-weight: 600;
        color: var(--gray-600);
        font-size: 0.5rem;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        margin-bottom: 0.25rem;
    }

    /* Hide label for cells without data-label */
    .table-mobile-cards td:not([data-label])::before {
        display: none;
    }

    .table-mobile-cards td > * {
        display: flex;
        margin-top: 0.5rem;
    }

    /* Ensure buttons and forms wrap properly in mobile cards */
    .table-mobile-cards td .btn-group,
    .table-mobile-cards td div[style*="display: flex"] {
        display: flex !important;
        justify-content: flex-start !important;
        flex-wrap: wrap;
        gap: 0.5rem;
        margin-top: 0.5rem;
    }

    .table-mobile-cards td .btn,
    .table-mobile-cards td button {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    /* Modal full screen on mobile */
    .modal-dialog {
        margin: 0;
        max-width: 100%;
        height: 100vh;
    }
    
    .modal-content {
        border-radius: 0;
        height: 100%;
    }
    
    /* Filters collapse on mobile */
    .filters-card .filters-grid {
        grid-template-columns: 1fr !important;
    }
}

/* Small mobile (< 576px) */
@media (max-width: 575.98px) {
    /* Typography */
    body {
        font-size: 14px;
    }
    
    h1 { font-size: 1.35rem; }
    h2 { font-size: 1.25rem; }
    h3 { font-size: 1.1rem; }
    
    /* Buttons smaller */
    .btn {
        padding: 0.5rem 1rem;
        font-size: 0.875rem;
    }
    
    .btn-sm {
        padding: 0.4rem 0.75rem;
        font-size: 0.8rem;
    }
    
    /* Form controls */
    .form-control {
        font-size: 14px;
        padding: 0.6rem 0.75rem;
    }
    
    /* Cards */
    .card {
        padding: 1rem;
    }
    
    /* Spacing adjustments */
    .mb-4 { margin-bottom: 1.5rem !important; }
    .mt-4 { margin-top: 1.5rem !important; }
    .p-4 { padding: 1rem !important; }
}

/* Landscape mobile */
@media (max-width: 767.98px) and (orientation: landscape) {
    .sidebar {
        width: 240px;
    }
}

/* Tablet specific (768px - 991px) */
@media (min-width: 768px) and (max-width: 991.98px) {
    /* Sidebar can be visible but narrower */
    .sidebar {
        width: 200px;
    }

    .main-content {
        margin-left: 200px;
        padding: 1.25rem;
    }

    /* Grid 2 columns */
    .card-grid,
    .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    /* Model selection 2 columns */
    .model-selection {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* Small laptop screens (13-inch) - 1280-1440px */
@media (min-width: 1200px) and (max-width: 1440px) {
    /* Reduce content padding for better space utilization */
    .main-content {
        padding: 1rem;
    }

    /* Optimize sidebar width */
    .sidebar {
        width: 200px;
    }

    .main-content {
        margin-left: 200px;
    }

    /* Stats cards - 3 columns max */
    .stats-grid,
    .card-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 1rem;
    }

    /* Model selection 3 columns */
    .model-selection {
        grid-template-columns: repeat(3, 1fr);
        gap: 1rem;
    }

    /* Compact table cells */
    table th,
    table td {
        padding: 0.6rem 0.8rem;
        font-size: 0.85rem;
    }

    /* Reduce form spacing */
    .form-group,
    .mb-3 {
        margin-bottom: 1rem;
    }
}

/* Large desktop (> 1440px) */
@media (min-width: 1441px) {
    /* Wider content on large screens */
    .container-fluid {
        max-width: 1400px;
        margin: 0 auto;
    }

    /* Model selection 4 columns */
    .model-selection {
        grid-template-columns: repeat(4, 1fr);
    }

    /* Stats grid 4-5 columns */
    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    }
}

/* Print styles */
@media print {
    .sidebar,
    .mobile-menu-toggle,
    .btn,
    .sidebar-overlay {
        display: none !important;
    }
    
    .main-content {
        margin-left: 0 !important;
        padding: 0 !important;
    }
    
    .page-header {
        border-bottom: 2px solid #000;
        margin-bottom: 1rem;
    }
}

/* Accessibility - Reduced motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
