/* ===== CSS VARIABLES ===== */
:root {
    --primary-color: #4F46E5;
    --primary-dark: #4338CA;
    --primary-light: #6366F1;
    --secondary-color: #10B981;
    --danger-color: #EF4444;
    --warning-color: #F59E0B;
    --info-color: #3B82F6;
    --dark-bg: #1F2937;
    --darker-bg: #111827;
    --light-bg: #F9FAFB;
    --card-bg: #FFFFFF;
    --text-primary: #111827;
    --text-secondary: #6B7280;
    --text-light: #9CA3AF;
    --border-color: #E5E7EB;
    --hover-bg: #F3F4F6;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --sidebar-width: 260px;
    --header-height: 70px;
}

/* ===== RESET & BASE STYLES ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--light-bg);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

/* ===== SIDEBAR ===== */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: linear-gradient(180deg, var(--dark-bg) 0%, var(--darker-bg) 100%);
    color: white;
    padding: 20px 0;
    transition: var(--transition);
    z-index: 1000;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
}

.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 20px 30px;
    font-size: 24px;
    font-weight: 700;
    color: white;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 20px;
}

.logo i {
    color: var(--primary-light);
    font-size: 28px;
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 0 12px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    border-radius: 8px;
    transition: var(--transition);
    font-weight: 500;
    font-size: 15px;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    transform: translateX(4px);
}

.nav-link.active {
    background: var(--primary-color);
    color: white;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.4);
}

.nav-link i {
    font-size: 18px;
    width: 20px;
    text-align: center;
}

/* ===== MAIN CONTENT ===== */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: var(--transition);
}

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

.header-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-primary);
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: var(--transition);
}

.menu-toggle:hover {
    background: var(--hover-bg);
}

.page-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.search-box {
    position: relative;
    display: flex;
    align-items: center;
}

.search-box i {
    position: absolute;
    left: 12px;
    color: var(--text-light);
    font-size: 16px;
}

.search-box input {
    padding: 10px 16px 10px 40px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    width: 280px;
    font-size: 14px;
    transition: var(--transition);
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.notification-btn {
    position: relative;
    background: none;
    border: none;
    font-size: 20px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: var(--transition);
}

.notification-btn:hover {
    background: var(--hover-bg);
    color: var(--primary-color);
}

.notification-btn .badge {
    position: absolute;
    top: 4px;
    right: 4px;
    background: var(--danger-color);
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 5px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px 6px 6px;
    background: var(--light-bg);
    border-radius: 25px;
    cursor: pointer;
    transition: var(--transition);
}

.user-profile:hover {
    box-shadow: var(--shadow-md);
}

.user-profile img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
}

.user-profile span {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
}

/* ===== PAGE CONTENT ===== */
.page-content {
    padding: 30px;
}

/* ===== COMING SOON ===== */
.coming-soon-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    text-align: center;
    padding: 40px;
}

.coming-soon-container h2 {
    color: var(--text-primary);
    margin-bottom: 10px;
    font-size: 28px;
}

.coming-soon-container p {
    color: var(--text-secondary);
    font-size: 16px;
}

/* ===== STATS CARDS ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 24px;
    margin-bottom: 30px;
}

.stat-card {
    background: white;
    padding: 24px;
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    display: flex;
    gap: 20px;
    align-items: flex-start;
    transition: var(--transition);
    border: 1px solid var(--border-color);
}

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

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: white;
    flex-shrink: 0;
}

.stat-icon.blue {
    background: linear-gradient(135deg, var(--info-color), var(--primary-color));
}

.stat-icon.green {
    background: linear-gradient(135deg, #10B981, #059669);
}

.stat-icon.purple {
    background: linear-gradient(135deg, #8B5CF6, #7C3AED);
}

.stat-icon.orange {
    background: linear-gradient(135deg, var(--warning-color), #F97316);
}

.stat-details h3 {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.stat-details p {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 8px;
    font-weight: 500;
}

.stat-change {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    color: var(--text-light);
}

.stat-change.positive {
    color: var(--secondary-color);
}

.stat-change.negative {
    color: var(--danger-color);
}

.stat-change i {
    font-size: 12px;
}

/* Stats Carousel Container */
.stats-carousel-container {
    position: relative;
    width: 100%;
    margin-bottom: 30px;
}

.stats-carousel {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
    overflow: hidden;
    scroll-behavior: smooth;
}

/* Carousel Navigation Buttons */
.carousel-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

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

.carousel-btn.prev {
    left: -20px;
}

.carousel-btn.next {
    right: -20px;
}

.carousel-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    pointer-events: none;
}

/* Carousel Indicators */
.carousel-indicators {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 20px;
}

.indicator-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--border-color);
    cursor: pointer;
    transition: all 0.3s ease;
}

.indicator-dot.active {
    background: var(--primary-color);
    width: 24px;
    border-radius: 4px;
}

/* Update stat-card to remove old change indicators */
.stat-card {
    background: var(--card-bg);
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    gap: 16px;
    align-items: center;
    min-width: 0;
    /* Allow cards to shrink in carousel */
}

/* Remove stat-change styles as we're not using them */
.stat-change {
    display: none;
}

/* Tablet: Show 2 cards */
@media (max-width: 1024px) {
    .stats-carousel {
        grid-template-columns: repeat(2, 1fr);
    }

    .carousel-btn.prev {
        left: -15px;
    }

    .carousel-btn.next {
        right: -15px;
    }
}

/* Mobile: Show 2 cards */
@media (max-width: 768px) {
    .stats-carousel {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }

    .carousel-btn {
        width: 32px;
        height: 32px;
        font-size: 12px;
    }

    .carousel-btn.prev {
        left: -10px;
    }

    .carousel-btn.next {
        right: -10px;
    }

    .stat-card {
        padding: 16px;
        flex-direction: column;
        text-align: center;
    }

    .stat-icon {
        margin-bottom: 8px;
    }
}

/* ===== CHARTS ===== */
.charts-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 24px;
    margin-bottom: 30px;
}

.chart-card {
    background: white;
    padding: 24px;
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.chart-header h3 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.chart-header select {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    background: white;
}

/* ===== ACTIVITY SECTION ===== */
.activity-section {
    background: white;
    padding: 24px;
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.section-header h3 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.activity-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.activity-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    transition: var(--transition);
}

.activity-item:hover {
    background: var(--hover-bg);
    border-color: var(--primary-light);
}

.activity-info h4 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.activity-info p {
    font-size: 13px;
    color: var(--text-secondary);
}

.activity-count {
    font-size: 16px;
    font-weight: 700;
    color: var(--primary-color);
    padding: 8px 16px;
    background: rgba(79, 70, 229, 0.1);
    border-radius: 6px;
}

/* ===== PAGE ACTIONS ===== */
.page-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    gap: 20px;
    flex-wrap: wrap;
}

.search-filter {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    flex: 1;
}

.search-input,
.filter-select {
    padding: 10px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    transition: var(--transition);
}

.search-input {
    flex: 1;
    min-width: 200px;
}

.search-input:focus,
.filter-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.action-buttons {
    display: flex;
    gap: 12px;
}

/* ===== BUTTONS ===== */
.btn-primary,
.btn-secondary {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
    white-space: nowrap;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.btn-secondary {
    background: var(--light-bg);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--hover-bg);
    border-color: var(--primary-color);
}

/* Icon-only buttons for mobile - add after line 400 */

/* Show full button text on larger screens */
@media (min-width: 769px) {
    .btn-icon-only .btn-text {
        display: inline;
        margin-left: 8px;
    }
}

/* ===== TABLE ===== */
.table-container {
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    border: 1px solid var(--border-color);
}

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

.data-table thead {
    background: var(--light-bg);
}

.data-table th {
    padding: 16px;
    text-align: left;
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    color: var(--text-secondary);
    letter-spacing: 0.5px;
}

.data-table tbody tr {
    border-bottom: 1px solid var(--border-color);
    transition: var(--transition);
}

.data-table tbody tr:hover {
    background: var(--hover-bg);
}

.data-table tbody tr:last-child {
    border-bottom: none;
}

.data-table td {
    padding: 16px;
    font-size: 14px;
    color: var(--text-primary);
}

.action-btn {
    padding: 8px 12px;
    border: none;
    background: var(--light-bg);
    color: var(--text-primary);
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition);
    margin-right: 4px;
}

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

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

.status-badge {
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    display: inline-block;
}

.status-badge.new {
    background: rgba(16, 185, 129, 0.1);
    color: var(--secondary-color);
}

.status-badge.existing {
    background: rgba(59, 130, 246, 0.1);
    color: var(--info-color);
}

/* ===== ANALYTICS ===== */
.analytics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 24px;
}

.analytics-card {
    background: white;
    padding: 24px;
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

.analytics-card h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 20px;
}

/* ===== UPLOAD SECTION ===== */
.upload-section {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
}

.upload-card {
    background: white;
    padding: 40px;
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    border: 2px dashed var(--border-color);
    text-align: center;
    transition: var(--transition);
}

.upload-card:hover {
    border-color: var(--primary-color);
    background: rgba(79, 70, 229, 0.02);
}

.upload-card i {
    font-size: 64px;
    color: var(--primary-light);
    margin-bottom: 20px;
}

.upload-card h3 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.upload-card p {
    color: var(--text-secondary);
    margin-bottom: 24px;
    font-size: 14px;
}

.upload-status {
    margin-top: 20px;
    padding: 12px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
}

.upload-status.success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--secondary-color);
}

.upload-status.error {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger-color);
}

.upload-history {
    background: white;
    padding: 24px;
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

.upload-history h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 16px;
}

/* ===== MODAL ===== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    /* ADD THIS */
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

.modal-header h3 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
}

.close-btn {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-light);
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    transition: var(--transition);
}

.close-btn:hover {
    background: var(--hover-bg);
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
    max-height: calc(90vh - 140px);
    /* ADD THIS - accounts for header and footer */
    overflow-y: auto;
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 14px;
}

.form-control {
    width: 100%;
    padding: 10px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    transition: var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

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

/* ===== STATUS BADGES ===== */
.status-badge.pending {
    background: rgba(249, 158, 11, 0.1);
    color: var(--warning-color);
}

.status-badge.approved {
    background: rgba(16, 185, 129, 0.1);
    color: var(--secondary-color);
}

.status-badge.rejected {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger-color);
}

.status-badge.salesperson {
    background: rgba(59, 130, 246, 0.1);
    color: var(--info-color);
}

.status-badge.supervisor {
    background: rgba(139, 92, 246, 0.1);
    color: #8B5CF6;
}

/* ===== LOGIN MODAL CENTERED ===== */
#loginModal .modal-content {
    max-width: 400px;
}

/* ===== FORM TEXTAREA ===== */
.form-control[rows] {
    resize: vertical;
    min-height: 80px;
}

/* ===== AUTOCOMPLETE DROPDOWN ===== */
.client-dropdown {
    position: absolute;
    width: 100%;
    max-height: 200px;
    overflow-y: auto;
    background: white;
    border: 1px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 8px 8px;
    box-shadow: var(--shadow-md);
    z-index: 1000;
    display: none;
}

.client-dropdown.active {
    display: block;
}

.client-dropdown-item {
    padding: 12px 16px;
    cursor: pointer;
    transition: var(--transition);
    border-bottom: 1px solid var(--border-color);
}

.client-dropdown-item:last-child {
    border-bottom: none;
}

.client-dropdown-item:hover {
    background: var(--hover-bg);
}

.client-dropdown-item strong {
    display: block;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.client-dropdown-item small {
    color: var(--text-secondary);
    font-size: 12px;
}

.client-not-found {
    display: block;
    margin-top: 8px;
    padding: 8px 12px;
    background: rgba(249, 158, 11, 0.1);
    color: var(--warning-color);
    border-radius: 6px;
    font-size: 13px;
}

.form-group {
    position: relative;
}

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

/* Tablets and below (max-width: 1024px) */
@media (max-width: 1024px) {
    :root {
        --sidebar-width: 240px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .charts-row {
        grid-template-columns: 1fr;
    }

    .analytics-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .upload-section {
        grid-template-columns: 1fr;
    }

    .search-box input {
        width: 200px;
    }
}

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

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

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

    .menu-toggle {
        display: block;
    }

    .header {
        padding: 0 16px;
    }

    .page-title {
        font-size: 20px;
    }

    .search-box {
        display: none;
    }

    .user-profile span {
        display: none;
    }

    .page-content {
        padding: 20px 16px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }

    .charts-row {
        gap: 16px;
    }

    .chart-card {
        padding: 16px;
    }

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

    .page-actions {
        flex-direction: column;
        align-items: stretch;
    }

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

    .data-table {
        min-width: 600px;
    }

    .modal-content {
        width: 95%;
        margin: 20px;
    }

    /* Icon-only buttons for mobile */
    .btn-icon-only {
        padding: 10px;
        min-width: 44px;
        width: 44px;
        height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .btn-icon-only i {
        margin: 0;
    }

    .btn-icon-only .btn-text {
        display: none;
    }

    /* Make action buttons container tighter */
    .action-buttons {
        flex-direction: row;
        gap: 8px;
        flex-shrink: 0;
    }

    /* Adjust page actions for mobile */
    .page-actions {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        flex-wrap: nowrap;
        gap: 12px;
    }

    .search-filter {
        flex-direction: column;
        flex: 1;
        min-width: 0;
        gap: 8px;
    }

    .search-input,
    .filter-select {
        width: 100%;
        min-width: 0;
    }

    /* ===== ENHANCED REPORTS PAGE MOBILE STYLES ===== */
    #reportsPage .page-actions {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        margin-bottom: 20px;
    }

    #reportsPage .search-filter {
        display: flex;
        flex-direction: column;
        gap: 10px;
        width: 100%;
        background: white;
        padding: 16px;
        border-radius: 12px;
        box-shadow: var(--shadow-sm);
    }

    #reportsPage .search-filter .date-range-container {
        display: grid;
        grid-template-columns: 1fr auto 1fr;
        gap: 8px;
        align-items: center;
    }

    #reportsPage .search-filter input[type="date"] {
        width: 100%;
    }

    #reportsPage .search-filter span {
        padding: 0 4px;
        color: var(--text-secondary);
        font-size: 12px;
        font-weight: 600;
    }

    #reportsPage .search-filter .btn-secondary {
        width: 100%;
        justify-content: center;
        padding: 12px;
    }

    #reportsPage .action-buttons {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
        width: 100%;
    }

    #reportsPage .action-buttons button {
        width: 100%;
        padding: 12px;
        justify-content: center;
    }

    #reportsPage .action-buttons .btn-icon-only {
        width: 100%;
        height: auto;
        padding: 12px;
    }

    #reportsPage .action-buttons .btn-icon-only .btn-text {
        display: inline;
        margin-left: 6px;
    }

    /* Stats grid for reports page */
    #reportsPage .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
        margin-bottom: 20px;
    }

    #reportsPage .stat-card {
        padding: 16px;
        gap: 12px;
    }

    #reportsPage .stat-icon {
        width: 48px;
        height: 48px;
        font-size: 20px;
    }

    #reportsPage .stat-details h3 {
        font-size: 24px;
    }

    #reportsPage .stat-details p {
        font-size: 12px;
    }

    /* Table improvements for reports page */
    #reportsPage .table-container {
        border-radius: 12px;
        margin-bottom: 20px;
    }

    #reportsPage .data-table {
        font-size: 13px;
    }

    #reportsPage .data-table th {
        padding: 12px 8px;
        font-size: 11px;
        position: sticky;
        top: 0;
        background: var(--light-bg);
        z-index: 10;
    }

    #reportsPage .data-table td {
        padding: 12px 8px;
        font-size: 13px;
        vertical-align: top;
    }

    #reportsPage .data-table td:nth-child(4),
    #reportsPage .data-table td:nth-child(5) {
        max-width: 150px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    #reportsPage .status-badge {
        font-size: 10px;
        padding: 4px 8px;
        white-space: nowrap;
    }
}

/* Small mobile devices (max-width: 480px) */
@media (max-width: 480px) {
    .header {
        height: 60px;
    }

    .page-title {
        font-size: 18px;
    }

    .stat-card {
        flex-direction: column;
        text-align: center;
    }

    .stat-details h3 {
        font-size: 28px;
    }

    .chart-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .chart-header select {
        width: 100%;
    }

    .activity-item {
        flex-direction: column;
        gap: 12px;
        text-align: center;
    }

    .data-table th,
    .data-table td {
        padding: 12px 8px;
        font-size: 13px;
    }

    /* ===== EXTRA SMALL SCREENS - REPORTS PAGE ===== */
    #reportsPage .search-filter {
        padding: 12px;
        gap: 8px;
    }

    #reportsPage .search-filter input[type="date"] {
        font-size: 14px;
        padding: 10px 12px;
    }

    #reportsPage .action-buttons {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    #reportsPage .stats-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    #reportsPage .stat-card {
        flex-direction: row;
        text-align: left;
        padding: 14px;
    }

    #reportsPage .stat-icon {
        width: 44px;
        height: 44px;
        font-size: 18px;
    }

    #reportsPage .stat-details h3 {
        font-size: 22px;
    }

    #reportsPage .data-table {
        min-width: 500px;
    }

    #reportsPage .data-table th,
    #reportsPage .data-table td {
        padding: 10px 6px;
        font-size: 12px;
    }
}

/* Large screens (min-width: 1400px) */
@media (min-width: 1400px) {
    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .charts-row {
        grid-template-columns: 1.5fr 1fr;
    }

    .analytics-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Print styles */
@media print {

    .sidebar,
    .header,
    .page-actions,
    .action-btn {
        display: none;
    }

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

    .page-content {
        padding: 0;
    }

    .stat-card,
    .chart-card,
    .table-container {
        box-shadow: none;
        border: 1px solid var(--border-color);
        page-break-inside: avoid;
    }
}

/* ===== CLIENT DETAIL PAGE ===== */
.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    flex-wrap: wrap;
    gap: 16px;
}

.btn-back {
    padding: 10px 20px;
    border: 1px solid var(--border-color);
    background: white;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
    color: var(--text-primary);
}

.btn-back:hover {
    background: var(--hover-bg);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.detail-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.client-detail-container {
    display: grid;
    gap: 24px;
}

/* Client Profile Card */
.client-profile-card {
    background: linear-gradient(160deg, var(--text-light), var(--dark-bg));
    padding: 15px;
    border-radius: 12px 12px 0 0;
    color: white;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 10px;
    text-align: left;
}

.profile-avatar {
    width: 60px;
    height: 60px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    color: white;
    border: 4px solid rgba(255, 255, 255, 0.3);
    flex-shrink: 0;
}

.profile-info {
    flex: 1;
}

.client-profile-card h2 {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 5px;
}

.client-category {
    font-size: 15px;
    opacity: 0.9;
    font-weight: 500;
}

/* Client Info Grid */
.client-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px;
}

.info-card {
    background: white;
    padding: 24px;
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

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

.info-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 2px solid var(--border-color);
}

.info-card-header i {
    font-size: 20px;
    color: var(--primary-color);
}

.info-card-header h3 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.info-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
}

.info-item:last-child {
    border-bottom: none;
}

.info-label {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 14px;
}

.info-value {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 14px;
    text-align: right;
}

/* Activity Timeline */
.activity-timeline {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.timeline-item {
    display: flex;
    gap: 16px;
    padding: 16px;
    background: var(--light-bg);
    border-radius: 8px;
    border-left: 4px solid var(--primary-color);
    transition: var(--transition);
}

.timeline-item:hover {
    background: white;
    box-shadow: var(--shadow-sm);
}

.timeline-icon {
    width: 40px;
    height: 40px;
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.timeline-content {
    flex: 1;
}

.timeline-date {
    font-size: 12px;
    color: var(--text-light);
    margin-bottom: 4px;
}

.timeline-title {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.timeline-description {
    font-size: 14px;
    color: var(--text-secondary);
}

/* Make client rows clickable */
#clientsTableBody tr {
    cursor: pointer;
    transition: var(--transition);
}

#clientsTableBody tr:hover {
    background: var(--hover-bg);
    transform: translateX(4px);
}

/* Responsive Design for Client Detail */
@media (max-width: 768px) {

    /* Client Detail Page Mobile Fix */
    .detail-header {
        flex-direction: row !important;
        align-items: center !important;
        justify-content: space-between !important;
        gap: 8px !important;
        flex-wrap: nowrap !important;
    }

    .btn-back {
        padding: 10px 12px !important;
        min-width: auto !important;
        flex-shrink: 0 !important;
        white-space: nowrap !important;
    }

    .btn-back span {
        display: none !important;
    }

    .detail-actions {
        display: flex !important;
        flex-direction: row !important;
        gap: 8px !important;
        flex-shrink: 0 !important;
        flex-wrap: nowrap !important;
    }

    .detail-actions button {
        width: auto !important;
        padding: 10px 12px !important;
        min-width: 40px !important;
        height: 40px !important;
        justify-content: center !important;
    }

    /* Hide all button text in detail actions */
    .detail-actions button {
        font-size: 0 !important;
    }

    .detail-actions button i {
        margin: 0 !important;
        font-size: 15px !important;
    }

    .client-profile-card {
        padding: 20px;
        gap: 16px;
    }

    .profile-avatar {
        width: 60px;
        height: 60px;
        font-size: 28px;
    }

    .client-profile-card h2 {
        font-size: 20px;
    }

    .client-category {
        font-size: 14px;
    }

    .client-info-grid {
        grid-template-columns: 1fr;
    }

    .info-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    .info-value {
        text-align: left;
    }
}

@media (max-width: 480px) {
    .client-profile-card {
        padding: 16px;
        gap: 12px;
    }

    .profile-avatar {
        width: 50px;
        height: 50px;
        font-size: 24px;
        border: 3px solid rgba(255, 255, 255, 0.3);
    }

    .client-profile-card h2 {
        font-size: 18px;
    }

    .client-category {
        font-size: 13px;
    }

    .info-card {
        padding: 16px;
    }

    .timeline-item {
        flex-direction: column;
    }
}

/* ===== CATEGORY DROPDOWN ===== */
.category-dropdown-wrapper {
    position: relative;
}

.category-dropdown-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-width: 180px;
    cursor: pointer;
    background: white;
    transition: var(--transition);
}

.category-dropdown-btn:hover {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.category-dropdown-btn i {
    font-size: 12px;
    transition: transform 0.3s ease;
}

.category-dropdown-btn.active i {
    transform: rotate(180deg);
}

.category-dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    min-width: 280px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    display: none;
    z-index: 1000;
    max-height: 400px;
    overflow-y: auto;
}

.category-dropdown-menu.active {
    display: block;
    animation: dropdownSlideIn 0.2s ease-out;
}

@keyframes dropdownSlideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.category-item {
    position: relative;
}

.category-item-btn {
    width: 100%;
    padding: 12px 16px;
    border: none;
    background: white;
    text-align: left;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    border-bottom: 1px solid var(--border-color);
}

.category-item:last-child .category-item-btn {
    border-bottom: none;
}

.category-item-btn:hover {
    background: var(--hover-bg);
    color: var(--primary-color);
}

.category-item-btn.selected {
    background: rgba(79, 70, 229, 0.1);
    color: var(--primary-color);
    font-weight: 600;
}

.category-item-content {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}

.category-item-icon {
    width: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
}

.category-item-name {
    flex: 1;
    font-size: 14px;
}

.category-item-count {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}

.category-item-arrow {
    font-size: 10px;
    color: var(--text-secondary);
}

/* Reset button */
.category-reset-btn {
    width: 100%;
    padding: 12px 16px;
    border: none;
    background: var(--light-bg);
    color: var(--primary-color);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    border-top: 2px solid var(--border-color);
    position: sticky;
    bottom: 0;
    z-index: 10;
}

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

/* ===== INDEPENDENT SUBMENU MODAL ===== */
.submenu-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2500;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.submenu-overlay.active {
    display: flex;
}

.submenu-modal {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    max-height: 70vh;
    overflow: hidden;
    box-shadow: var(--shadow-xl);
    animation: submenuModalSlideIn 0.3s ease-out;
}

@keyframes submenuModalSlideIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(-20px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.submenu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 2px solid var(--border-color);
    background: var(--light-bg);
}

.submenu-header h3 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

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

.submenu-close-btn {
    background: none;
    border: none;
    font-size: 20px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: var(--transition);
}

.submenu-close-btn:hover {
    background: var(--hover-bg);
    color: var(--text-primary);
}

.submenu-body {
    padding: 12px;
    max-height: calc(70vh - 60px);
    overflow-y: auto;
}

.submenu-option {
    width: 100%;
    padding: 14px 16px;
    border: none;
    background: white;
    text-align: left;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-radius: 8px;
    margin-bottom: 6px;
    font-size: 15px;
    border: 1px solid var(--border-color);
}

.submenu-option:hover {
    background: var(--hover-bg);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.submenu-option.selected {
    background: rgba(79, 70, 229, 0.1);
    color: var(--primary-color);
    font-weight: 600;
    border-color: var(--primary-color);
}

.submenu-count {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
    background: var(--light-bg);
    padding: 4px 8px;
    border-radius: 4px;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .category-dropdown-btn {
        min-width: 140px;
        font-size: 13px;
    }

    .category-dropdown-menu {
        min-width: 260px;
        right: 0;
        left: auto;
    }

    .submenu-modal {
        width: 95%;
        max-width: 95%;
    }

    .submenu-header h3 {
        font-size: 16px;
    }

    .submenu-option {
        padding: 12px 14px;
        font-size: 14px;
    }
}

/* Show submenu on HOVER (desktop) or when parent is CLICKED/ACTIVE (mobile) */
.category-item:hover>.subcategory-menu,
.category-item.show-submenu>.subcategory-menu {
    display: block;
    opacity: 1;
    pointer-events: auto;
    animation: submenuSlideIn 0.2s ease-out forwards;
}

/* Keep submenu visible when hovering over it */
.subcategory-menu:hover {
    display: block;
    opacity: 1;
    pointer-events: auto;
}

@keyframes submenuSlideIn {
    from {
        opacity: 0;
        transform: translateX(-5px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.subcategory-item {
    position: relative;
}

.subcategory-item-btn {
    width: 100%;
    padding: 10px 16px;
    border: none;
    background: white;
    text-align: left;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: 14px;
    border-bottom: 1px solid var(--border-color);
}

.subcategory-item:last-child .subcategory-item-btn {
    border-bottom: none;
}

.subcategory-item-btn:hover {
    background: var(--hover-bg);
    color: var(--primary-color);
}

.subcategory-item-btn.selected {
    background: rgba(79, 70, 229, 0.1);
    color: var(--primary-color);
    font-weight: 600;
}

/* Reset button */
.category-reset-btn {
    width: 100%;
    padding: 12px 16px;
    border: none;
    background: var(--light-bg);
    color: var(--primary-color);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    border-top: 2px solid var(--border-color);
    position: sticky;
    bottom: 0;
    z-index: 10;
}

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

/* Mobile Responsive */
@media (max-width: 768px) {
    .category-dropdown-btn {
        min-width: 140px;
        font-size: 13px;
    }

    .category-dropdown-menu {
        min-width: 260px;
        right: 0;
        left: auto;
    }

    /* On mobile, show submenu as modal overlay */
    .subcategory-menu {
        position: fixed;
        left: 50% !important;
        top: 50% !important;
        transform: translate(-50%, -50%) !important;
        margin-left: 0;
        max-width: 90vw;
        max-height: 70vh;
        overflow-y: auto;
        box-shadow: var(--shadow-xl);
        z-index: 2001;
    }

    .category-item:hover>.subcategory-menu {
        animation: modalSlideIn 0.3s ease-out forwards;
    }
}

/* External nav link - looks like nav-link but works as regular link */
.nav-link-external {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    border-radius: 8px;
    transition: var(--transition);
    font-weight: 500;
    font-size: 15px;
}

.nav-link-external:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    transform: translateX(4px);
}

.nav-link-external i {
    font-size: 18px;
    width: 20px;
    text-align: center;
}