/* ========== RESET & BASE ========== */
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
        }

        /* Design system variables are in design-system.css */
        :root {
            /* Legacy variables for backward compatibility */
            --primary: var(--color-primary, #1a3a5c);
            --secondary: var(--color-secondary, #2c5aa0);
            --accent: var(--color-primary, #1a3a5c);
            --success: var(--color-success, #27ae60);
            --danger: var(--color-danger, #e74c3c);
            --warning: var(--color-warning, #f39c12);
            --info: var(--color-info, #2c5aa0);
            --light: var(--color-bg-light, #f5f7fa);
            --dark: var(--color-text, #1a3a5c);
            --gray: var(--color-text-light, #6c757d);
            --border: var(--color-border, #e0e0e0);
            --shadow: var(--shadow-md, rgba(26, 58, 92, 0.1));
        }

        body {
            background: #f5f7fa;
            color: var(--dark);
            -webkit-font-smoothing: antialiased;
            -moz-osx-font-smoothing: grayscale;
            overflow-x: hidden;
        }
        
        /* Prevent horizontal scroll on mobile */
        html, body {
            max-width: 100%;
            overflow-x: hidden;
            width: 100%;
            position: relative;
        }
        
        /* Force all containers to respect viewport */
        * {
            box-sizing: border-box;
        }

        /* ========== LOGIN PAGE ========== */
        /* Auth layout is now in auth-layout.css */
        /* Only application-specific overrides remain here */
        
        .eh-logo {
            display: flex;
            flex-direction: column;
            align-items: flex-start;
            gap: 8px;
        }
        
        .eh-letters {
            display: flex;
            align-items: center;
            gap: 8px;
            margin-bottom: 5px;
        }
        
        .letter-e {
            font-size: 64px;
            font-weight: bold;
            color: #2c5aa0;
            line-height: 1;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
        }
        
        .eh-connector {
            width: 30px;
            height: 15px;
            margin: 0 -5px;
            flex-shrink: 0;
        }
        
        .letter-h {
            font-size: 64px;
            font-weight: bold;
            color: #7f8c8d;
            line-height: 1;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            position: relative;
        }
        
        .letter-h::before {
            content: '';
            position: absolute;
            left: 0;
            top: 0;
            width: 8px;
            height: 100%;
            background: #7f8c8d;
            border-radius: 2px;
        }
        
        .letter-h::after {
            content: '';
            position: absolute;
            right: 0;
            top: 0;
            width: 8px;
            height: 100%;
            background: #7f8c8d;
            border-radius: 2px;
        }
        
        .eh-text {
            display: flex;
            flex-direction: column;
            align-items: flex-start;
            gap: 2px;
            margin-left: 0;
        }
        
        .text-tax {
            font-size: 32px;
            font-weight: bold;
            color: #2c5aa0;
            line-height: 1;
        }
        
        .text-accountants {
            font-size: 18px;
            font-weight: 600;
            color: #7f8c8d;
            line-height: 1.2;
        }
        
        .eh-tagline {
            font-size: 11px;
            color: #7f8c8d;
            letter-spacing: 1px;
            margin-top: 8px;
            font-weight: 500;
        }
        
        /* Sidebar Logo */
        .eh-logo-sidebar {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            gap: 4px;
            margin-bottom: 10px;
            width: 100%;
        }
        
        .eh-letters-small {
            display: flex;
            align-items: center;
            gap: 4px;
            margin-bottom: 2px;
        }
        
        .letter-e-small {
            font-size: 28px;
            font-weight: bold;
            color: var(--accent);
            line-height: 1;
        }
        
        .eh-connector-small {
            width: 12px;
            height: 8px;
            margin: 0 -2px;
            flex-shrink: 0;
        }
        
        .letter-h-small {
            font-size: 28px;
            font-weight: bold;
            color: rgba(255,255,255,0.7);
            line-height: 1;
            position: relative;
        }
        
        .letter-h-small::before {
            content: '';
            position: absolute;
            left: 0;
            top: 0;
            width: 4px;
            height: 100%;
            background: rgba(255,255,255,0.7);
            border-radius: 1px;
        }
        
        .letter-h-small::after {
            content: '';
            position: absolute;
            right: 0;
            top: 0;
            width: 4px;
            height: 100%;
            background: rgba(255,255,255,0.7);
            border-radius: 1px;
        }
        
        .eh-text-small {
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 1px;
        }
        
        .text-tax-small {
            font-size: 16px;
            font-weight: bold;
            color: var(--accent);
            line-height: 1;
        }
        
        .text-accountants-small {
            font-size: 10px;
            font-weight: 600;
            color: rgba(255,255,255,0.8);
            line-height: 1.2;
        }
        
        /* ========== LOGIN STYLES ========== */
        /* Auth layout styles are now in auth-layout.css */
        /* Only application-specific overrides remain here */

        .feature-icon {
            width: 40px;
            height: 40px;
            background: rgba(255,255,255,0.1);
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        /* Login styles moved to auth-layout.css for better organization */

        /* ========== FORMS ========== */
        /* Form styles are now in components.css and portal-styles.css */
        /* Keeping minimal base for compatibility */

        .input-with-icon {
            position: relative;
        }

        .input-with-icon i {
            position: absolute;
            left: 15px;
            top: 50%;
            transform: translateY(-50%);
            color: var(--gray);
        }

        .input-with-icon input {
            padding-left: 45px;
        }

        /* ========== BUTTONS ========== */
        /* Button styles are now in components.css and portal-styles.css */
        /* Keeping minimal base for compatibility */

        /* Button variants are now in components.css and portal-styles.css */

        /* ========== PORTAL ========== */
        /* App layout is now in app-layout.css */
        /* Auth layout is now in auth-layout.css */
        /* Only application-specific overrides remain here */

        /* ========== LAYOUT ========== */
        /* App layout is now in app-layout.css */
        /* Auth layout is now in auth-layout.css */
        /* Only application-specific overrides remain here */

        /* ========== SECTIONS ========== */
        .section {
            display: none;
            animation: fadeIn 0.3s ease;
        }

        .section.active {
            display: block;
        }

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

        /* ========== DASHBOARD ========== */
        /* Dashboard components are now in components.css */
        /* Only application-specific overrides remain here */

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

        /* ========== CARDS ========== */
        /* Card styles are now in components.css and portal-styles.css */
        /* Keeping minimal base for compatibility */

        /* ========== TABLES ========== */
        .table-responsive {
            overflow-x: auto;
        }

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

        .table th {
            background: #f8f9fa;
            padding: 15px;
            text-align: left;
            font-weight: 600;
            color: var(--primary);
            border-bottom: 2px solid #eaeaea;
        }

        .table td {
            padding: 15px;
            border-bottom: 1px solid #eaeaea;
        }

        .table tr:hover {
            background: #f8f9fa;
        }

        /* ========== BADGES ========== */
        /* Badge styles are now in components.css and portal-styles.css */
        /* Keeping minimal base for compatibility */

        /* ========== MODALS ========== */
        /* Modal styles are now in components.css and portal-styles.css */
        /* Base modal structure for JavaScript compatibility */
        .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;
            padding: 20px;
            box-sizing: border-box;
        }

        .modal.active {
            display: flex;
            animation: fadeIn 0.3s ease;
        }

        .modal-header {
            padding: 25px 30px;
            background: var(--primary);
            color: white;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .modal-title {
            font-size: 20px;
            margin: 0;
        }

        .modal-close {
            background: none;
            border: none;
            color: white;
            font-size: 28px;
            cursor: pointer;
        }

        .modal-body {
            padding: 30px;
            max-height: 60vh;
            overflow-y: auto;
        }

        .modal-footer {
            padding: 20px 30px;
            background: #f8f9fa;
            border-top: 1px solid #eaeaea;
            display: flex;
            justify-content: flex-end;
            gap: 10px;
        }

        /* ========== ALERTS ========== */
        .alert {
            padding: 15px 20px;
            border-radius: 8px;
            margin-bottom: 20px;
            display: none;
            animation: slideIn 0.3s ease;
        }

        .alert.show {
            display: block;
        }

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

        .alert-success {
            background: #d4edda;
            color: #155724;
            border: 1px solid #c3e6cb;
        }

        .alert-danger {
            background: #f8d7da;
            color: #721c24;
            border: 1px solid #f5c6cb;
        }

        /* ========== CHAT SYSTEM ========== */
        /* Mobile-first: Stack vertically on mobile */
        .chat-container {
            display: flex;
            flex-direction: column;
            gap: 16px;
            width: 100%;
            max-width: 100%;
            height: calc(100vh - 200px);
            min-height: 500px;
            overflow: hidden;
            box-sizing: border-box;
        }

        .chat-sidebar {
            width: 100%;
            max-width: 100%;
            height: 200px;
            min-height: 200px;
            max-height: 200px;
            background: white;
            border-radius: 10px;
            overflow: hidden;
            flex-shrink: 0;
            display: flex;
            flex-direction: column;
            box-sizing: border-box;
        }

            .chat-header {
                padding: 15px 20px;
                background: var(--primary);
                color: white;
                flex-shrink: 0;
            }
            
            .chat-header-title {
                font-size: 16px;
                margin-bottom: 8px;
            }

            .chat-search {
                position: relative;
                margin-top: 8px;
                flex-shrink: 0;
            }
            
            .chat-search input {
                padding: 8px 12px 8px 35px;
                font-size: 14px;
            }

        .chat-search input {
            width: 100%;
            padding: 10px 15px 10px 40px;
            border: none;
            border-radius: 20px;
            background: rgba(255,255,255,0.9);
        }

        .chat-search i {
            position: absolute;
            left: 15px;
            top: 50%;
            transform: translateY(-50%);
            color: var(--gray); /* Original: Light gray */
        }
        
        .chat-search input::placeholder {
            color: var(--color-text-lighter); /* Original: Very light gray */
            opacity: 1;
        }

        .chat-list {
            flex: 1;
            overflow-y: auto;
            padding: 10px;
        }

        .chat-item {
            padding: 15px;
            border-radius: 8px;
            cursor: pointer;
            margin-bottom: 10px;
            transition: background 0.3s;
        }

        .chat-item:hover, .chat-item.active {
            background: #f5f7fa;
        }

        .chat-item-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 5px;
        }

        .chat-item-name {
            font-weight: 600;
            color: var(--primary); /* Professional: Primary color for names */
        }

        .chat-item-time {
            font-size: 12px;
            color: var(--gray); /* Original: Light gray */
        }

        .chat-item-message {
            color: var(--gray); /* Original: Light gray */
            font-size: 14px;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .chat-unread {
            background: var(--danger);
            color: white;
            padding: 2px 8px;
            border-radius: 10px;
            font-size: 11px;
            margin-top: 5px;
            display: inline-block;
        }

        .chat-window {
            flex: 1;
            min-height: 0;
            background: white;
            border-radius: 10px;
            display: flex;
            flex-direction: column;
            overflow: hidden;
            width: 100%;
            max-width: 100%;
            box-sizing: border-box;
        }

        .chat-window-header {
            padding: 16px;
            background: #f8f9fa;
            border-bottom: 1px solid #eaeaea;
            display: flex;
            justify-content: space-between;
            align-items: center;
            flex-shrink: 0;
            width: 100%;
            max-width: 100%;
            box-sizing: border-box;
        }

        .chat-messages {
            flex: 1;
            min-height: 0;
            padding: 16px;
            overflow-y: auto;
            overflow-x: hidden;
            display: flex;
            flex-direction: column;
            width: 100%;
            max-width: 100%;
            box-sizing: border-box;
            -webkit-overflow-scrolling: touch;
            gap: 15px;
            /* Hide scrollbar on mobile for cleaner look */
            scrollbar-width: thin;
            scrollbar-color: rgba(0, 0, 0, 0.2) transparent;
        }
        
        .chat-messages::-webkit-scrollbar {
            width: 4px;
        }
        
        .chat-messages::-webkit-scrollbar-track {
            background: transparent;
        }
        
        .chat-messages::-webkit-scrollbar-thumb {
            background: rgba(0, 0, 0, 0.2);
            border-radius: 2px;
        }
        
        .chat-messages::-webkit-scrollbar-thumb:hover {
            background: rgba(0, 0, 0, 0.3);
        }

        .message {
            max-width: 70%;
            padding: 12px 16px;
            border-radius: 18px;
            position: relative;
            overflow: visible !important;
            overflow-x: visible !important;
            overflow-y: visible !important;
            height: auto !important;
            min-height: auto !important;
            max-height: none !important;
            word-wrap: break-word;
            overflow-wrap: break-word;
            white-space: normal;
        }

        .message.sent {
            background: var(--secondary);
            color: white;
            align-self: flex-end;
            border-bottom-right-radius: 5px;
        }

        .message.received {
            background: #f0f2f5;
            color: var(--dark);
            align-self: flex-start;
            border-bottom-left-radius: 5px;
        }

        .message-time {
            font-size: 11px;
            opacity: 0.7;
            margin-top: 5px;
            text-align: right;
        }

        .chat-input {
            padding: 12px 16px;
            border-top: 1px solid #eaeaea;
            display: flex;
            gap: 10px;
            flex-shrink: 0;
            width: 100%;
            max-width: 100%;
            box-sizing: border-box;
            background: white;
            position: sticky;
            bottom: 0;
        }

        /* Ensure chat input is visible when not hidden */
        .chat-input:not([hidden]) {
            display: flex !important;
        }

        .chat-input input {
            flex: 1 1 auto;
            min-width: 0;
            padding: 12px 16px;
            border: 1px solid #ddd;
            border-radius: 25px;
            font-size: 16px; /* Prevent zoom on iOS */
            width: 100%;
            max-width: 100%;
            box-sizing: border-box;
        }
        
        .chat-input .btn {
            flex: 0 0 auto;
            flex-shrink: 0;
            min-width: 44px;
            max-width: 44px;
            width: 44px;
            min-height: 44px;
            height: 44px;
            border-radius: 50%;
            padding: 0;
            display: flex;
            align-items: center;
            justify-content: center;
        }
        
        .chat-input .btn i {
            font-size: 18px;
        }

        /* ========== TAX CALCULATOR ========== */
        /* Tax Form Layout */
        .tax-form-grid {
            display: grid;
            grid-template-columns: repeat(2, 1fr);
            gap: 20px;
            margin-bottom: 20px;
        }

        .tax-form-buttons {
            display: flex;
            gap: 10px;
            margin-top: 20px;
            flex-wrap: wrap;
        }

        .tax-form-buttons .btn {
            flex: 1;
            min-width: 140px;
        }

        /* Tax Result Section */
        .tax-result {
            background: #f8f9fa;
            border-radius: 10px;
            padding: 25px;
            margin-top: 30px;
            display: none;
        }

        .tax-result-title {
            color: var(--primary);
            margin-bottom: 20px;
            font-size: 1.5rem;
            font-weight: 600;
        }

        .tax-result-buttons {
            display: flex;
            gap: 10px;
            margin-top: 20px;
            justify-content: center;
        }

        .tax-result-buttons .btn {
            min-width: 200px;
        }

        /* Result Grids */
        .result-grid {
            display: grid;
            gap: 15px;
            margin-bottom: 20px;
        }

        .result-grid-main {
            grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        }

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

        .result-grid-final {
            grid-template-columns: repeat(3, 1fr);
        }

        .result-item {
            background: white;
            padding: 18px;
            border-radius: 8px;
            text-align: center;
            box-shadow: 0 2px 5px rgba(0,0,0,0.1);
            transition: transform 0.2s ease, box-shadow 0.2s ease;
        }

        .result-item:hover {
            transform: translateY(-2px);
            box-shadow: 0 4px 8px rgba(0,0,0,0.15);
        }

        .result-item-highlight {
            background: linear-gradient(135deg, #e3f2fd 0%, #f8f9fa 100%);
            border: 2px solid var(--primary);
        }

        .result-label {
            color: var(--gray);
            font-size: 13px;
            margin-bottom: 10px;
            line-height: 1.4;
            font-weight: 500;
        }

        .result-label-sub {
            display: block;
            font-size: 11px;
            color: #999;
            font-weight: normal;
            margin-top: 2px;
        }

        .result-value {
            font-size: 22px;
            color: var(--primary);
            font-weight: bold;
            word-wrap: break-word;
            line-height: 1.3;
        }

        .result-value-highlight {
            font-size: 24px;
            color: var(--success);
        }

        /* Tax Calculator Reference Section */
        .tax-brackets-reference {
            margin-top: 30px;
            padding: 20px;
            background: #f8f9fa;
            border-radius: 10px;
            border-left: 4px solid var(--secondary);
        }

        .tax-brackets-title {
            color: var(--primary);
            margin-bottom: 15px;
            font-size: 1.1rem;
            font-weight: 600;
        }

        .tax-brackets-list {
            display: grid;
            gap: 10px;
        }

        .tax-brackets-list-small {
            gap: 8px;
            font-size: 0.9rem;
        }

        .tax-bracket-item {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 8px 0;
            border-bottom: 1px solid #eee;
        }

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

        .tax-bracket-rate {
            font-weight: 600;
            color: var(--primary);
        }

        .tax-bracket-free {
            color: var(--success);
        }

        .tax-brackets-nonresident {
            margin-top: 15px;
            padding-top: 15px;
            border-top: 1px solid #ddd;
        }

        .tax-brackets-subtitle {
            color: var(--primary);
            margin-bottom: 10px;
            font-size: 0.9rem;
            font-weight: 600;
        }

        .tax-brackets-note {
            margin-top: 8px;
            padding: 8px;
            background: rgba(231, 76, 60, 0.1);
            border-radius: 4px;
            font-size: 0.75rem;
            color: var(--danger);
            line-height: 1.4;
        }

        /* ========== DOCUMENTS ========== */
        /* Document components are now in components.css */

        /* ========== RESPONSIVE DESIGN ========== */
        
        /* ===== TABLET (481px - 1024px) ===== */
        @media (max-width: 1024px) and (min-width: 769px) {
            /* Tax Calculator - Tablet */
            .tax-form-grid {
                grid-template-columns: 1fr;
                gap: 15px;
            }

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

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

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

            .result-item:last-child {
                grid-column: 1 / -1;
            }

            /* Layout rules moved to app-layout.css and layout-override.css */
            /* .sidebar {
                width: 260px;
            }
            
            .main-content {
                margin-left: 260px !important;
                width: calc(100% - 260px) !important;
                max-width: calc(100% - 260px) !important;
            } */
            
            /* Content area padding and grid layouts handled in app-layout.css and components.css */
        }

        /* ===== MOBILE & TABLET (481px - 768px) ===== */
        @media (max-width: 768px) {
            /* Login Page styles moved to auth-layout.css */
            
            /* Sidebar */
            .sidebar {
                width: 280px;
                max-width: 85vw; /* Max 85% of viewport width */
            }
            
            .sidebar-header {
                padding: 20px 15px;
                width: 100%;
                box-sizing: border-box;
            }
            
            .eh-logo-sidebar-image {
                max-width: 140px !important;
                max-height: 50px !important;
            }
            
            .user-profile {
                padding: 15px;
                width: 100%;
                box-sizing: border-box;
            }
            
            .user-avatar {
                width: 45px;
                height: 45px;
                font-size: 18px;
            }
            
            /* Topbar */
            .topbar {
                padding: 12px 15px;
                flex-wrap: wrap;
                width: 100%;
                max-width: 100%;
                box-sizing: border-box;
            }
            
            .topbar-left {
                flex: 1;
                min-width: 0;
            }
            
            .page-title {
                font-size: 18px;
                white-space: nowrap;
                overflow: hidden;
                text-overflow: ellipsis;
            }
            
            .topbar-right {
                gap: 10px;
                flex-shrink: 0;
            }
            
            .user-menu span {
                display: none;
            }
            
            .notification-btn {
                padding: 8px;
                min-width: 44px;
                min-height: 44px;
                display: flex;
                align-items: center;
                justify-content: center;
            }
            
            /* Content Area */
            .content-area {
                padding: 15px;
                width: 100%;
                max-width: 100%;
                overflow-x: hidden;
                box-sizing: border-box;
            }
            
            /* Layout and grid rules handled in app-layout.css and components.css */
            
            img, video, iframe {
                max-width: 100%;
                height: auto;
            }
            
            .stat-card {
                padding: 20px;
            }
            
            .stat-icon {
                font-size: 24px;
            }
            
            .stat-value {
                font-size: 24px;
            }
            
            .quick-actions {
                grid-template-columns: 1fr;
                gap: 10px;
            }
            
            .btn {
                padding: 12px 20px;
                font-size: 14px;
                width: 100%;
                max-width: 100%;
                justify-content: center;
                box-sizing: border-box;
                white-space: normal;
                word-wrap: break-word;
            }
            
            /* In inline input groups (like Client ID generator), the button
               must stay compact so the text field remains readable on phone. */
            .input-group .btn {
                width: auto;
                max-width: none;
                min-width: 44px;
                flex: 0 0 auto;
                justify-content: center;
            }
            
            .btn-sm {
                padding: 8px 12px;
                font-size: 13px;
                white-space: nowrap;
            }
            
            /* Card styles handled in components.css */
            
            /* Tables */
            .table-responsive {
                overflow-x: auto;
                -webkit-overflow-scrolling: touch;
                width: 100%;
                max-width: 100%;
                display: block;
                position: relative;
                margin-left: -15px;
                margin-right: -15px;
                padding-left: 15px;
                padding-right: 15px;
            }
            
            .table {
                font-size: 14px;
                width: 100%;
                min-width: 700px; /* Minimum width for table content */
                table-layout: auto;
            }
            
            .table th,
            .table td {
                padding: 10px 8px;
                white-space: nowrap;
                font-size: 13px;
            }
            
            .table th:first-child,
            .table td:first-child {
                padding-left: 15px;
            }
            
            .table th:last-child,
            .table td:last-child {
                padding-right: 15px;
            }

            /* User Management Section - Search bar */
            #userManagementSection .user-search-wrapper {
                display: flex !important;
                width: 100%;
            }
            #userManagementSection .user-search-wrapper .input-with-icon {
                flex: 1;
                min-width: 0;
            }

            /* User Management Section - Mobile Fixes */
            #userManagementSection .card-body {
                overflow-x: visible !important;
                padding-left: 0;
                padding-right: 0;
            }

            #userManagementSection .table-responsive {
                margin-left: -20px;
                margin-right: -20px;
                padding-left: 20px;
                padding-right: 20px;
                overflow-x: auto !important;
                -webkit-overflow-scrolling: touch;
                width: calc(100% + 40px);
                position: relative;
                /* Ensure scrollbar is visible */
                scrollbar-width: thin;
                scrollbar-color: var(--primary) transparent;
            }

            #userManagementSection .table-responsive::-webkit-scrollbar {
                height: 8px;
            }

            #userManagementSection .table-responsive::-webkit-scrollbar-track {
                background: #f1f1f1;
                border-radius: 4px;
            }

            #userManagementSection .table-responsive::-webkit-scrollbar-thumb {
                background: var(--primary);
                border-radius: 4px;
            }

            #userManagementSection .table {
                min-width: 900px; /* Increased to fit all columns including Actions with 3 buttons */
            }

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

            #userManagementSection .table th:first-child,
            #userManagementSection .table td:first-child {
                padding-left: 20px;
            }

            #userManagementSection .table th:last-child,
            #userManagementSection .table td:last-child {
                padding-right: 20px;
            }

            /* Actions column - wider to fit all buttons */
            #userManagementSection .table th:last-child,
            #userManagementSection .table td:last-child {
                white-space: nowrap;
                min-width: 200px !important; /* Increased for 3 buttons (32px each + margins) */
                width: auto;
                padding-left: 10px;
                padding-right: 20px;
            }

            /* Compact action buttons on mobile */
            #userManagementSection .btn-sm {
                padding: 5px 6px;
                font-size: 11px;
                min-width: 32px;
                height: 32px;
                margin: 2px 1px;
                display: inline-flex;
                align-items: center;
                justify-content: center;
            }

            #userManagementSection .btn-sm i {
                font-size: 11px;
            }

            /* Remove text from buttons on mobile, icon only */
            #userManagementSection .btn-sm {
                padding: 5px;
                width: 32px;
                min-width: 32px;
            }

            /* Hide less critical columns on very small screens */
            @media (max-width: 480px) {
                #userManagementSection .table th:nth-child(3),
                #userManagementSection .table td:nth-child(3) {
                    display: none; /* Hide Email column on very small screens */
                }

                /* Make Actions column even wider on very small screens */
                #userManagementSection .table th:last-child,
                #userManagementSection .table td:last-child {
                    min-width: 200px !important;
                }

                /* Further reduce button size */
                #userManagementSection .btn-sm {
                    padding: 4px;
                    width: 30px;
                    min-width: 30px;
                    height: 30px;
                    margin: 1px;
                }
            }
            
            /* Chat - Mobile optimized */
            .chat-container {
                height: calc(100vh - 180px);
                min-height: 500px;
                max-height: calc(100vh - 180px);
            }
            
            .chat-sidebar {
                height: auto;
                min-height: 400px;
                max-height: calc(100vh - 280px);
                flex: 1 1 auto;
                overflow: hidden;
                display: flex;
                flex-direction: column;
            }
            
            .chat-list {
                flex: 1;
                min-height: 250px;
                overflow-y: auto;
                overflow-x: hidden;
                -webkit-overflow-scrolling: touch;
                padding: 10px;
                scrollbar-width: thin;
                scrollbar-color: var(--primary) transparent;
            }
            
            .chat-list::-webkit-scrollbar {
                width: 6px;
            }
            
            .chat-list::-webkit-scrollbar-track {
                background: transparent;
            }
            
            .chat-list::-webkit-scrollbar-thumb {
                background: var(--primary);
                border-radius: 3px;
            }
            
            .chat-item {
                padding: 14px;
                margin-bottom: 10px;
                min-height: 65px;
                border-radius: 10px;
                background: #f8f9fa;
                transition: background 0.2s;
            }
            
            .chat-item:active {
                background: #e9ecef;
            }
            
            .chat-item-header {
                display: flex;
                justify-content: space-between;
                align-items: center;
                margin-bottom: 6px;
            }
            
            .chat-item-name {
                font-weight: 600;
                font-size: 15px;
                color: var(--primary);
            }
            
            .chat-item-time {
                font-size: 12px;
                color: var(--gray);
            }
            
            .chat-item-message {
                font-size: 13px;
                color: var(--gray);
                overflow: hidden;
                text-overflow: ellipsis;
                white-space: nowrap;
            }
            
            .chat-window {
                min-height: 350px;
                display: none; /* Hidden by default on mobile */
            }
            
            /* Show chat window and hide sidebar when chat is active on mobile */
            .chat-container.chat-active .chat-sidebar {
                display: none !important;
            }
            
            .chat-container.chat-active .chat-window {
                display: flex !important;
                flex-direction: column;
                width: 100%;
                height: 100%;
                min-height: 100%;
            }
            
            /* Hide scrollbar in chat messages on mobile for cleaner look */
            .chat-messages {
                scrollbar-width: none !important;
                -ms-overflow-style: none !important;
            }
            
            .chat-messages::-webkit-scrollbar {
                display: none !important;
                width: 0 !important;
                height: 0 !important;
            }
            
            /* Chat back button styling */
            .chat-back-btn {
                transition: transform 0.2s;
                background: none !important;
                border: none !important;
                color: var(--primary) !important;
                font-size: 20px !important;
                cursor: pointer;
                padding: 8px;
                display: flex;
                align-items: center;
                justify-content: center;
                min-width: 40px;
                min-height: 40px;
            }
            
            .chat-back-btn:active {
                transform: scale(0.9);
            }
            
            .chat-back-btn:hover {
                opacity: 0.8;
            }
            
            .message {
                max-width: 85%;
                padding: 10px 14px;
                font-size: 14px;
                word-wrap: break-word;
                overflow-wrap: break-word;
                overflow: visible !important;
                overflow-x: visible !important;
                overflow-y: visible !important;
                height: auto !important;
                min-height: auto !important;
                max-height: none !important;
                white-space: normal;
            }
            
            .message > div {
                overflow: visible !important;
                height: auto !important;
                max-height: none !important;
            }
            
            /* Document grid and card styles handled in components.css */
            
            /* Tax Calculator Form */
            .tax-form-grid {
                grid-template-columns: 1fr !important;
                gap: 15px !important;
            }

            .tax-form-buttons {
                flex-direction: column;
            }

            .tax-form-buttons .btn {
                width: 100%;
                min-width: auto;
            }

            /* Tax Calculator Results */
            .tax-result {
                padding: 20px 15px;
                width: 100%;
                max-width: 100%;
                box-sizing: border-box;
                margin-top: 20px;
            }

            .tax-result-title {
                font-size: 1.25rem;
                margin-bottom: 15px;
            }
            
            .result-grid {
                grid-template-columns: 1fr !important;
                gap: 12px;
                width: 100%;
                max-width: 100%;
            }

            .result-grid-main,
            .result-grid-secondary,
            .result-grid-final {
                grid-template-columns: 1fr !important;
            }
            
            .result-item {
                width: 100%;
                max-width: 100%;
                box-sizing: border-box;
                padding: 15px;
            }

            .result-label {
                font-size: 12px;
            }

            .result-label-sub {
                font-size: 10px;
            }
            
            .result-value {
                font-size: 18px;
                word-wrap: break-word;
            }

            .result-value-highlight {
                font-size: 20px;
            }

            .tax-result-buttons {
                flex-direction: column;
                gap: 10px;
            }

            .tax-result-buttons .btn {
                width: 100%;
            }

            /* Tax Calculator Reference Section */
            .tax-brackets-reference {
                padding: 15px;
                margin-top: 20px;
            }

            .tax-brackets-title {
                font-size: 1rem;
                margin-bottom: 12px;
            }

            .tax-brackets-subtitle {
                font-size: 0.85rem;
            }

            .tax-brackets-list {
                gap: 8px;
            }

            .tax-bracket-item {
                padding: 6px 0;
                font-size: 0.9rem;
            }

            .tax-brackets-list-small {
                font-size: 0.85rem;
            }

            .tax-brackets-note {
                font-size: 0.7rem;
                padding: 6px;
            }
            
            /* Modals */
            .modal {
                padding: 0;
                align-items: flex-end;
                justify-content: center;
            }
            
            .modal-content {
                max-width: 100% !important;
                width: 100% !important;
                max-height: 90vh;
                border-radius: 15px 15px 0 0;
                margin: 0;
                display: flex;
                flex-direction: column;
                box-sizing: border-box;
            }
            
            .modal-header {
                padding: 20px;
                width: 100%;
                box-sizing: border-box;
                flex-shrink: 0;
            }
            
            .modal-title {
                font-size: 18px;
                word-wrap: break-word;
                padding-right: 40px;
            }
            
            .modal-body {
                padding: 20px;
                max-height: calc(90vh - 140px);
                overflow-y: auto;
                overflow-x: hidden;
                -webkit-overflow-scrolling: touch;
                width: 100%;
                box-sizing: border-box;
            }
            
            .modal-footer {
                padding: 15px 20px;
                flex-direction: column;
                width: 100%;
                box-sizing: border-box;
                flex-shrink: 0;
                gap: 10px;
            }
            
            .modal-footer .btn {
                width: 100%;
                max-width: 100%;
                margin: 0;
                box-sizing: border-box;
            }
            
            .modal-close {
                width: 44px;
                height: 44px;
                display: flex;
                align-items: center;
                justify-content: center;
                min-width: 44px;
                min-height: 44px;
            }
            
            /* Forms */
            .form-group {
                margin-bottom: 15px;
                width: 100%;
                max-width: 100%;
                box-sizing: border-box;
            }
            
            .form-group label {
                width: 100%;
                display: block;
                margin-bottom: 8px;
                font-size: 14px;
            }
            
            .form-control {
                padding: 12px 15px;
                font-size: 16px !important; /* Prevents zoom on iOS */
                width: 100%;
                max-width: 100%;
                box-sizing: border-box;
                border-radius: 8px;
            }
            
            .input-with-icon {
                width: 100%;
                max-width: 100%;
                box-sizing: border-box;
            }
            
            .input-with-icon input {
                width: 100%;
                max-width: 100%;
                box-sizing: border-box;
            }
            
            .input-with-icon i {
                position: absolute;
                left: 15px;
                top: 50%;
                transform: translateY(-50%);
                pointer-events: none;
            }
            
            /* Form grids on mobile - force single column */
            form > div[style*="grid"],
            form > div[style*="display: grid"],
            .form-group[style*="grid"] {
                grid-template-columns: 1fr !important;
                display: grid !important;
                gap: 15px !important;
            }
            
            /* Textarea */
            textarea.form-control {
                width: 100%;
                max-width: 100%;
                min-height: 100px;
                resize: vertical;
            }
            
            /* Select dropdowns */
            select.form-control {
                width: 100%;
                max-width: 100%;
                box-sizing: border-box;
                -webkit-appearance: none;
                -moz-appearance: none;
                appearance: none;
                background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23333' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
                background-repeat: no-repeat;
                background-position: right 15px center;
                padding-right: 40px;
            }
            
            /* File input */
            input[type="file"] {
                width: 100%;
                max-width: 100%;
            }
            
            /* Navigation */
            .nav-link {
                padding: 12px 15px;
                font-size: 14px;
            }
            
            .nav-icon {
                width: 22px;
            }
            
            /* Feature Items (Login Page) */
            .feature-item {
                flex-direction: column;
                text-align: center;
                gap: 10px;
            }
            
            .feature-icon {
                width: 50px;
                height: 50px;
            }
        }
        
        /* ===== SMALL MOBILE (320px - 480px) ===== */
        @media (max-width: 480px) {
            /* Login styles moved to auth-layout.css */
            
            /* Topbar */
            .topbar {
                padding: 10px 12px;
            }
            
            .page-title {
                font-size: 16px;
                flex: 1;
            }
            
            .menu-toggle {
                font-size: 20px;
                padding: 8px;
            }
            
            /* Content */
            .content-area {
                padding: 12px;
            }
            
            /* Cards */
            .card-header {
                padding: 12px 15px;
            }
            
            .card-body {
                padding: 12px;
            }
            
            /* Stats */
            .stat-card {
                padding: 15px;
            }
            
            .stat-icon {
                font-size: 22px;
            }
            
            .stat-label {
                font-size: 12px;
            }
            
            .stat-value {
                font-size: 22px;
            }
            
            /* Buttons */
            .btn {
                padding: 10px 16px;
                font-size: 13px;
            }
            
            .btn-sm {
                padding: 5px 8px;
                font-size: 11px;
            }
            
            /* Tables */
            .table {
                font-size: 12px;
            }
            
            .table th,
            .table td {
                padding: 8px 6px;
            }
            
            /* Chat */
            .chat-sidebar {
                height: 200px;
            }
            
            .chat-header {
                padding: 15px;
            }
            
            .chat-header h3 {
                font-size: 16px;
            }
            
            .message {
                max-width: 90%;
                padding: 8px 12px;
                font-size: 13px;
                overflow: visible !important;
                overflow-x: visible !important;
                overflow-y: visible !important;
                height: auto !important;
                min-height: auto !important;
                max-height: none !important;
                white-space: normal;
            }
            
            .message > div {
                overflow: visible !important;
                height: auto !important;
                max-height: none !important;
            }
            
            /* Modals */
            .modal-content {
                border-radius: 10px 10px 0 0;
            }
            
            .modal-header {
                padding: 15px;
            }
            
            .modal-title {
                font-size: 16px;
            }
            
            .modal-body {
                padding: 15px;
            }
            
            .modal-footer {
                padding: 12px 15px;
            }
            
            /* Forms */
            .form-group label {
                font-size: 13px;
            }
            
            .form-control {
                padding: 10px 12px;
                font-size: 16px;
            }
            
            /* User Profile */
            .user-profile {
                flex-direction: column;
                text-align: center;
                padding: 12px;
            }
            
            .user-details {
                width: 100%;
                text-align: center;
            }
            
            .user-details h4 {
                font-size: 14px;
            }
            
            .user-details p {
                font-size: 11px;
            }
            
            /* Navigation */
            .nav-menu {
                padding: 10px 0;
                width: 100%;
                overflow-y: auto;
                -webkit-overflow-scrolling: touch;
            }
            
            .nav-item {
                margin: 3px 10px;
                width: calc(100% - 20px);
            }
            
            .nav-link {
                padding: 12px 15px;
                font-size: 13px;
                width: 100%;
                box-sizing: border-box;
            }
            
            /* Sidebar Footer */
            .sidebar-footer {
                padding: 15px;
            }
        }
        
        /* ===== EXTRA SMALL MOBILE (max-width: 360px) ===== */
        @media (max-width: 360px) {
            body, html {
                overflow-x: hidden !important;
                width: 100% !important;
                max-width: 100vw !important;
            }
            
            .content-area {
                padding: 10px;
                width: 100%;
                max-width: 100vw;
                box-sizing: border-box;
            }
            
            .card {
                width: 100%;
                max-width: 100%;
            }
            
            .card-body {
                padding: 10px;
                width: 100%;
                max-width: 100%;
                box-sizing: border-box;
            }

            /* Allow horizontal scroll for user management table */
            #userManagementSection {
                overflow-x: visible !important;
            }

            #userManagementSection .card-body {
                overflow-x: visible !important;
            }
            
            .card-header {
                padding: 10px 12px;
            }
            
            .stat-card {
                padding: 12px;
                width: 100%;
                max-width: 100%;
            }
            
            .stat-value {
                font-size: 20px;
            }
            
            .btn {
                padding: 10px 14px;
                font-size: 13px;
                width: 100%;
                max-width: 100%;
            }
            
            .topbar {
                padding: 8px 10px;
            }
            
            .page-title {
                font-size: 14px;
            }
            
            .modal-header {
                padding: 12px;
            }
            
            .modal-body {
                padding: 12px;
            }
            
            .modal-footer {
                padding: 10px 12px;
            }
            
            .sidebar {
                width: 250px;
                max-width: 85vw;
            }
            
            .chat-container {
                height: calc(100vh - 160px);
                min-height: 400px;
                max-height: calc(100vh - 160px);
            }
            
            .chat-sidebar {
                height: auto;
                min-height: 350px;
                max-height: calc(100vh - 260px);
                flex: 1 1 auto;
            }
            
            .chat-list {
                min-height: 200px;
            }
        }
        
        /* ===== TABLET & DESKTOP (min-width: 769px) ===== */
        @media (min-width: 769px) {
            /* Chat - Desktop side-by-side layout */
            .chat-container {
                flex-direction: row;
                height: 600px;
                min-height: 600px;
            }
            
            .chat-sidebar {
                width: 320px;
                min-width: 320px;
                max-width: 320px;
                height: 100%;
                min-height: 100%;
                max-height: 100%;
                border-radius: 10px;
            }
            
            .chat-window {
                flex: 1;
                min-width: 0;
                height: 100%;
                border-radius: 10px;
            }
        }
        
        /* ===== LARGE DESKTOP (min-width: 1440px) ===== */
        @media (min-width: 1440px) {
            .content-area {
                max-width: 1400px;
                margin: 0 auto;
            }
            
            .dashboard-grid {
                grid-template-columns: repeat(4, 1fr);
            }
            
            /* Documents grid: keep responsive to available width (prevents right-side clipping) */
            .documents-grid {
                grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
            }
            
            /* Chat - Wider sidebar on large screens */
            .chat-sidebar {
                width: 360px;
                min-width: 360px;
                max-width: 360px;
            }
        }
        
        /* ===== MOBILE KEYBOARD HANDLING ===== */
        @media (max-width: 768px) {
            /* Use dvh (dynamic viewport height) to handle mobile keyboards */
            .portal-container {
                height: 100dvh;
                max-height: 100dvh;
            }
            
            .chat-container {
                height: calc(100dvh - 180px);
                max-height: calc(100dvh - 180px);
            }
            
            /* Fallback for browsers that don't support dvh */
            @supports not (height: 100dvh) {
                .portal-container {
                    height: 100vh;
                }
                
                .chat-container {
                    height: calc(100vh - 180px);
                }
            }
        }
        
        /* ===== TOUCH DEVICE ENHANCEMENTS ===== */
        @media (hover: none) and (pointer: coarse) {
            /* Better touch targets */
            .btn {
                min-height: 44px;
                min-width: 44px;
            }
            
            .nav-link {
                min-height: 44px;
            }
            
            .chat-item {
                min-height: 60px;
                padding: 12px;
            }
            
            .modal-close {
                width: 44px;
                height: 44px;
                display: flex;
                align-items: center;
                justify-content: center;
            }
            
            /* Remove hover effects on touch devices */
            .btn:hover {
                transform: none;
            }
            
            .stat-card:hover {
                transform: none;
            }
            
            /* Better scrolling */
            * {
                -webkit-overflow-scrolling: touch;
            }
        }
        
        /* Touch device specific styles */
        .touch-device .btn {
            min-height: 44px;
        }
        
        .touch-device .nav-link {
            min-height: 44px;
        }
        
        /* Sidebar backdrop is controlled in app-layout.css (single source of truth) */
        
        /* Improve scrolling on mobile */
        @media (max-width: 768px) {
            .chat-list,
            .chat-messages,
            .modal-body,
            .content-area {
                -webkit-overflow-scrolling: touch;
                overscroll-behavior: contain;
            }
            
            /* Prevent horizontal scroll on all elements */
            * {
                max-width: 100%;
                overflow-x: hidden;
            }
            
            /* Chat Input - Mobile Optimized */
            .chat-input {
                padding: 10px 12px;
                gap: 8px;
                display: flex;
                align-items: center;
            }

            .chat-input input {
                flex: 1 1 auto !important;
                min-width: 0;
                max-width: none !important;
                width: auto !important;
                padding: 10px 14px;
                font-size: 16px; /* Prevent zoom on iOS */
                box-sizing: border-box;
                margin-right: 8px;
            }
            
            .chat-input .btn {
                flex: 0 0 44px !important;
                flex-shrink: 0 !important;
                min-width: 44px !important;
                max-width: 44px !important;
                width: 44px !important;
                height: 44px !important;
                padding: 0 !important;
                border-radius: 50%;
                display: flex;
                align-items: center;
                justify-content: center;
            }
            
            .chat-input .btn i {
                font-size: 16px;
                margin: 0;
            }
            
            /* Ensure messages don't overflow */
            .message {
                max-width: 85%;
                word-wrap: break-word;
                overflow-wrap: break-word;
                word-break: break-word;
                overflow: visible !important;
                overflow-x: visible !important;
                overflow-y: visible !important;
                height: auto !important;
                min-height: auto !important;
                max-height: none !important;
                white-space: normal;
            }
            
            .message > div {
                overflow: visible !important;
                height: auto !important;
                max-height: none !important;
                white-space: normal;
            }
        }
        
        /* Better input handling on mobile - prevent zoom */
        @media (max-width: 768px) {
            input:not([type="submit"]):not([type="button"]):not([type="reset"]),
            textarea,
            select {
                font-size: 16px !important; /* Prevents zoom on iOS */
            }
        }
        
        /* Improve table scrolling on mobile */
        .table-responsive {
            -webkit-overflow-scrolling: touch;
            scrollbar-width: thin;
        }

        /* Dashboard Conversation Items */
        .dashboard-conversation-item {
            transition: background 0.2s ease, transform 0.1s ease;
        }

        .dashboard-conversation-item:active {
            transform: scale(0.98);
        }

        .dashboard-conversation-item:hover {
            background: #f8f9fa !important;
        }
        
        /* Better modal animation on mobile */
        @media (max-width: 768px) {
            .modal.active {
                align-items: flex-end;
                padding-bottom: 0;
            }
            
            .modal-content {
                animation: slideUp 0.3s ease;
            }
            
            @keyframes slideUp {
                from {
                    transform: translateY(100%);
                }
                to {
                    transform: translateY(0);
                }
            }
        }
        
        /* ===== LANDSCAPE MOBILE ===== */
        @media (max-width: 768px) and (orientation: landscape) {
            .login-container {
                max-height: 100vh;
            }
            
            .login-left {
                padding: 20px;
            }
            
            .chat-container {
                height: calc(100vh - 150px);
            }
            
            .chat-sidebar {
                height: 200px;
            }
        }
        
        /* ===== PRINT STYLES ===== */
        @media print {
            .sidebar,
            .topbar,
            .btn,
            .modal,
            .notification-btn {
                display: none !important;
            }
            
            .main-content {
                margin-left: 0;
                width: 100%;
            }
            
            .content-area {
                padding: 0;
            }
        }

        /* ========== RECIPIENT SEARCH (New Message Modal) ========== */
        .recipient-search-wrapper {
            position: relative;
        }
        .recipient-dropdown-list {
            position: absolute;
            top: 100%;
            left: 0;
            right: 0;
            max-height: 240px;
            overflow-y: auto;
            background: #fff;
            border: 1px solid var(--border, #e0e0e0);
            border-top: none;
            border-radius: 0 0 8px 8px;
            box-shadow: var(--shadow-md, 0 4px 8px rgba(0,0,0,0.1));
            z-index: 1000;
            display: none;
        }
        .recipient-dropdown-list.show {
            display: block;
        }
        .recipient-dropdown-list .recipient-item {
            padding: 10px 14px;
            cursor: pointer;
            border-bottom: 1px solid #f0f0f0;
            transition: background 0.15s;
        }
        .recipient-dropdown-list .recipient-item:hover {
            background: rgba(26, 58, 92, 0.08);
        }
        .recipient-dropdown-list .recipient-item:last-child {
            border-bottom: none;
        }
        .recipient-dropdown-list .recipient-item .recipient-name {
            font-weight: 500;
            color: var(--dark);
        }
        .recipient-dropdown-list .recipient-item .recipient-role {
            font-size: 0.85em;
            color: var(--gray);
        }
        .recipient-dropdown-list .recipient-empty {
            padding: 16px;
            text-align: center;
            color: var(--gray);
        }

        /* ========== UTILITY ========== */
        .text-center { text-align: center; }
        .text-right { text-align: right; }
        .text-muted { color: var(--gray); }
        .mt-20 { margin-top: 20px; }
        .mb-20 { margin-bottom: 20px; }
        .mt-30 { margin-top: 30px; }
        .mb-30 { margin-bottom: 30px; }
        .d-flex { display: flex; }
        .align-center { align-items: center; }
        .justify-between { justify-content: space-between; }
        .gap-10 { gap: 10px; }
        .gap-15 { gap: 15px; }
        .gap-20 { gap: 20px; }
        .w-100 { width: 100%; }
        .cursor-pointer { cursor: pointer; }
        
        /* ========== GLOBAL RESPONSIVE FIXES ========== */
        /* Ensure all elements respect container width */
        * {
            max-width: 100%;
        }
        
        /* Prevent overflow on all containers */
        .container, 
        .section,
        .card,
        .modal-content,
        .form-control,
        .btn,
        img,
        video,
        iframe {
            max-width: 100%;
            box-sizing: border-box;
        }
        
        /* All responsive layout rules are now handled by app-layout.css and components.css */
        /* These files use mobile-first approach and handle all viewport constraints */