/* ============================================================
   FIN FORCE - MOBILE ADAPTATION STYLESHEET
   Mobile-first responsive design for devices <600px width
   ============================================================ */

@media (max-width: 600px) {
 
    /* ========== RESPONSIVE RESET ========== */
    .login-modal {
        display: flex !important;
    }
    .blocked-stats-btn {
      min-width: 50px;  
        
    }
    .login-modal.hidden {
        display: none !important;
    }

    .role-modal {
        display: none !important;
    }

    .role-modal.visible {
        display: flex !important;
    }

    .detail-modal {
        display: none !important;
    }

    .detail-modal.visible {
        display: flex !important;
    }
    
    .detail-header-row {
            display: flex;
            gap: 10px;
            font-size: 8px;
            color: var(--text-secondary);
        }

    #app {
        display: none !important;
    }

    #app.visible {
        display: flex !important;
    }

    #addnotesmodal {
        display: none !important;
    }

    #addnotesmodal[style*="display: flex"],
    #addnotesmodal[style*="display: flex;"] {
        display: flex !important;
    }
    #backToListBtn {
        max-height: 33px !important;
        padding: 0 12px;
        font-size: 13px;
        font-weight: 500;
        min-width: 44px;
        flex-shrink: 0; 
        
    }
   .back-to-list-btn {
     max-height: 33px !important;
     min-width: 50px
    ;
        padding: 0 12px;
        font-size: 13px;
        font-weight: 500;
        min-width: 44px;
        flex-shrink: 0;   
   }
    .contact-modal {
        display: none !important;
    }

    .contact-modal[style*="display: flex"],
    .contact-modal[style*="display: flex;"] {
        display: flex !important;
    }

    #notesModal {
        display: none !important;
    }

    #notesModal.visible {
        display: flex !important;
    }

    #notesModal[style*="display: flex"],
    #notesModal[style*="display: flex;"] {
        display: flex !important;
    }

    #noteDetailsModal {
        display: none !important;
    }

    #noteDetailsModal[style*="display: flex"],
    #noteDetailsModal[style*="display: flex;"] {
        display: flex !important;
    }

    #contactLogModal {
        display: none !important;
    }

    #contactLogModal[style*="display: flex"],
    #contactLogModal[style*="display: flex;"] {
        display: flex !important;
    }

    #contactEditModal {
        display: none !important;
    }

    #contactEditModal[style*="display: flex"],
    #contactEditModal[style*="display: flex;"] {
        display: flex !important;
    }

    #contactDetailsModal {
        display: none !important;
    }

    #contactDetailsModal[style*="display: flex"],
    #contactDetailsModal[style*="display: flex;"] {
        display: flex !important;
    }

    #contactHistoryModal {
        display: none !important;
    }

    #contactHistoryModal[style*="display: flex"],
    #contactHistoryModal[style*="display: flex;"] {
        display: flex !important;
    }

    #documentNumberFilterModal {
        display: none !important;
    }

    #documentNumberFilterModal[style*="display: flex"],
    #documentNumberFilterModal[style*="display: flex;"] {
        display: flex !important;
    }

    #reasonCodeModal {
        display: none !important;
    }

    #reasonCodeModal.visible {
        display: flex !important;
    }

    #reasonCodeAgingModal {
        display: none !important;
    }

    #reasonCodeAgingModal.visible {
        display: flex !important;
    }

    * {
        -webkit-text-size-adjust: 100%;
        -moz-text-size-adjust: 100%;
    }

    html {
        height: 100%;
        overflow-y: auto;
    }

    body {
        font-size: 14px;
        line-height: 1.5;
        overflow-x: hidden !important;
        width: 100%;
    }

    /* ========== HEADER ADAPTATION ========== */
    .app-header {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        height: 64px;
        padding: 0 16px;
        gap: 12px;
        z-index: 100;
        display: flex;
        align-items: center;
        flex-wrap: nowrap;
    }

    .app-title {
        margin-left: -20px;
        font-size: 18px !important;
        font-weight: 700;
        white-space: nowrap;
    }


    .market-stats-btn {
        display: none !important;
    }
    .uploadMarketData-btn {
        display: none !important;
    }
    .adminPanel-btn {
        display: none !important;
    }
    .notesAndRequests-btn {
        display: none !important;
    }
    .logout-btn {
        display: none !important;
    }

    .app-header-spacer {
        flex: 1;
    }

    /* ========== APP CONTENT ========== */
    .app-content {
        margin-top: 64px;
        padding: 5px !important;
        height: calc(100vh - 64px);
        overflow-y: auto !important;
        overflow-x: hidden !important;
        -webkit-overflow-scrolling: touch;
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
        gap: 5px !important;
    }

    /* ========== APP LOBBY LAYOUT (EXPANDABLE CARDS) ========== */
    .apps-container {
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
        height: 100% !important;
    }

    .app-panel {
        flex: none !important;
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
        border: none !important;
        border-right: none !important;
        background: transparent !important;
        justify-content: flex-start !important;
        align-items: stretch !important;
    }

    .app-panel::before {
        display: none !important;
    }

    .app-panel.left,
    .app-panel.center,
    .app-panel.right {
        border: none !important;
        border-right: none !important;
        background: transparent !important;
    }

    .app-panel.left,
    .app-panel.right {
        display: none !important;
    }

    .app-panel-content {
        display: flex !important;
        flex-direction: column !important;
        align-items: stretch !important;
        width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    .app-panel-content:hover {
        transform: none !important;
    }

    .app-panel:hover .app-panel-content {
        transform: none !important;
    }

    .app-card {
        width: 100% !important;
        max-width: none !important;
        padding: 16px !important;
        margin: 0 !important;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08) !important;
        border: 1px solid var(--border-color) !important;
        background: var(--surface-color) !important;
        min-height: auto !important;
        box-sizing: border-box !important;
    }

    .app-name {
        font-size: 18px !important;
        margin: 0 0 12px 0 !important;
        padding: 0 !important;
    }

    .app-description {
        font-size: 13px !important;
        margin: 12px 0 0 0 !important;
        line-height: 1.4 !important;
    }

    .app-features {
        font-size: 12px !important;
        margin: 12px 0 0 0 !important;
    }

    .app-features li {
        font-size: 12px !important;
    }

    .app-button {
        width: 100% !important;
        padding: 10px 12px !important;
        font-size: 14px !important;
        margin-top: 12px !important;
        cursor: pointer !important;
    }

    .app-panel:hover .app-card {
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08) !important;
        border-color: var(--border-color) !important;
    }



    /* ========== CONTROLS SECTION ========== */
    .controls-section {
        display: flex;
        flex-direction: column;
        gap: 12px;
        margin-bottom: 20px;
    }

    .control-group {
        width: 100%;
        display: flex;
        flex-direction: column;
        gap: 6px;
    }

    .control-group label {
        font-size: 13px;
        font-weight: 600;
        color: var(--text-secondary);
    }

    .market-selector,
    .search-input {
        width: 100%;
        min-height: 44px;
        padding: 12px 12px;
        font-size: 16px;
        border: 1px solid var(--border-color);
        border-radius: 6px;
        background: var(--surface-color);
        color: var(--text-primary);
        -webkit-appearance: none;
        appearance: none;
    }

    .market-selector:focus,
    .search-input:focus {
        outline: none;
        border-color: var(--primary-color);
        box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
    }

    .segment-checkboxes-container2 {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 8px !important;
        padding: 10px !important;
        background: var(--surface-color) !important;
        border: 1px solid var(--border-color) !important;
        border-radius: 6px !important;
        width: 100% !important;
    }

    .division-checkboxes-container {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 8px !important;
        padding: 10px !important;
        background: var(--surface-color) !important;
        border: 1px solid var(--border-color) !important;
        border-radius: 6px !important;
        width: 100% !important;
    }

    .segment-checkbox-item2 {
        display: flex !important;
        align-items: center !important;
        gap: 8px !important;
        font-size: 14px !important;
        padding: 4px 0 !important;
    }

    .division-checkbox-item {
        display: flex !important;
        align-items: center !important;
        gap: 8px !important;
        font-size: 14px !important;
        padding: 4px 0 !important;
    }

    .segment-checkbox-item2 input[type="checkbox"] {
        width: 18px !important;
        height: 18px !important;
        margin: 0 !important;
    }

    .division-checkbox-item input[type="checkbox"] {
        width: 18px !important;
        height: 18px !important;
        margin: 0 !important;
    }

    .hidden {
        display: none !important;
    }

    /* ========== CLIENT LIST - TABLE VIEW ========== */

    
    #clientsContainer {
        overflow-x: visible !important;
    }

    .clients-table {
        width: 100% !important;
        max-width: 100% !important;
        min-width: auto !important;
        border-collapse: collapse;
        background: var(--surface-color);
        border: 1px solid var(--border-color);
        border-radius: 8px;
        overflow: hidden;
        font-size: 12px;
    }

    .clients-table thead {
        display: table-header-group;
        background: var(--background-color);
        border-bottom: 2px solid var(--border-color);
    }

    .clients-table thead tr {
        display: table-row;
    }

    .clients-table thead th {
        font-weight: 600;
        color: var(--text-secondary);
        font-size: 11px;
        padding: 8px 6px;
        text-align: left;
        border: none;
    }

    .clients-table tbody {
        display: table-row-group;
    }

    .clients-table tbody tr {
        display: table-row;
        border-bottom: 1px solid var(--border-color);
        cursor: pointer;
        transition: background-color 0.2s;
    }

    .clients-table tbody tr:hover {
        background-color: var(--hover-color);
    }

    .clients-table td {
        padding: 8px 6px;
        font-size: 12px;
        border: none;
        white-space: normal;
        word-wrap: break-word;
    }

    /* Show only Market (1), Customer Name (3), Total Overdue (10) */
    .clients-table td:nth-child(1) {
        width: 20%;
        font-weight: 600;
        color: var(--text-secondary);
        font-size: 11px;
    }

    .clients-table td:nth-child(3) {
        width: 50%;
        font-weight: 600;
        color: var(--text-primary);
        font-size: 12px;
    }

    .clients-table td:nth-child(10) {
        width: 30%;
        text-align: right;
        font-weight: 600;
        color: var(--text-primary);
    }

    /* Hide Account Number (2), columns 4-9, 11-12 */
    .clients-table td:nth-child(4),
    .clients-table td:nth-child(5),
    .clients-table td:nth-child(6),
    .clients-table td:nth-child(7),
    .clients-table td:nth-child(8),
    .clients-table td:nth-child(9),
    .clients-table td:nth-child(11),
    .clients-table td:nth-child(12),
    .clients-table th:nth-child(4),
    .clients-table th:nth-child(5),
    .clients-table th:nth-child(6),
    .clients-table th:nth-child(7),
    .clients-table th:nth-child(8),
    .clients-table th:nth-child(9),
    .clients-table th:nth-child(11),
    .clients-table th:nth-child(12) {
        display: none;
    }

    .clients-table td.currency {
        text-align: right;
        font-family: 'Courier New', monospace;
        font-weight: 500;
    }

    .clients-table td.total-overdue-value {
        color: #dc2626;
        font-weight: 700;
        font-size: 13px;
    }

    .clients-table td.highlight-overdue {
        background-color: transparent;
    }

    .clients-table tbody tr:hover td.highlight-overdue {
        background-color: transparent;
    }

    /* ========== PAGINATION ========== */
    .pagination-controls {
        display: none;
        gap: 12px;
        align-items: center;
        justify-content: center;
        margin-top: 20px;
        padding: 16px;
        background-color: var(--background-color);
        border-radius: 6px;
        flex-wrap: wrap;
    }

    .pagination-controls.visible {
        display: flex;
    }

    .pagination-btn {
        padding: 8px 12px;
        background: var(--surface-color);
        color: var(--text-primary);
        border: 1px solid var(--border-color);
        border-radius: 6px;
        cursor: pointer;
        font-size: 13px;
        font-weight: 500;
        min-height: 40px;
        transition: all 0.2s;
    }

    .pagination-btn:hover:not(:disabled) {
        background: var(--hover-color);
        border-color: var(--primary-color);
        color: var(--primary-color);
    }

    .pagination-btn:disabled {
        opacity: 0.5;
        cursor: not-allowed;
    }

    .page-indicator {
        font-size: 13px;
        color: var(--text-secondary);
        font-weight: 600;
        min-width: 100px;
        text-align: center;
    }

    /* ========== DETAIL VIEW LAYOUT ========== */
    .detail-header {
        background: var(--surface-color);
        border: 1px solid var(--border-color);
        border-radius: 8px;
        padding: 16px;
        margin-bottom: 20px;
    }

    .detail-header-info h2 {
        font-size: 18px;
        margin: 0 0 12px 0;
        color: var(--text-primary);
    }

    .detail-header-row {
        display: flex;
        flex-direction: column;
        gap: 8px;
        font-size: 12px;
        line-height: 1.4;
    }

    .detail-header-row span {
        white-space: normal;
        word-break: break-word;
    }

    .detail-header-row strong {
        color: var(--text-secondary);
        font-weight: 600;
    }

    .total-overdue-value {
        color: #dc2626;
        font-weight: 700;
    }

    .detail-content {
        display: flex;
        flex-direction: column;
        gap: 20px;
    }

    .detail-main {
        width: 100%;
        order: 1;
    }

    .detail-main h3 {
        font-size: 16px;
        margin: 0 0 16px 0;
        color: var(--text-primary);
    }

    .detail-sidebar {
        width: 100%;
        order: 2;
        display: flex;
        flex-direction: column;
        gap: 20px;
        padding-left: 5px;
        padding-top: 5px;
        padding-right: 5px;
        padding-bottom: 5px;
    }

    /* ========== INVOICE FILTERS ========== */
    .invoice-filters {
        display: flex;
        flex-direction: column;
        gap: 0px !important;
        margin-bottom: 0px !important;
        border: 0px !important;
        padding: 0px !important;
        background: #f8fafc  !important;
    }

    .invoice-filters .filter-group {
        display: flex;
        gap: 8px;
        align-items: center;
        flex-wrap: wrap;
    }

    .invoice-filters .filter-group label {
        font-weight: 600;
        font-size: 12px;
        white-space: nowrap;
    }

    .invoice-filters .filter-group select,
    .invoice-filters .filter-group button {
        min-height: 36px;
        font-size: 12px;
    }

    /* Hide non-essential filters on mobile */
    .invoice-filters .filter-group:nth-child(2),
    .invoice-filters .filter-group:nth-child(3),
    .invoice-filters .filter-group:nth-child(4),
    .invoice-filters .filter-group:nth-child(5) {
        display: none;
    }

    /* Show only first filter group (Status) and selected invoices summary if present */
    .invoice-filters .filter-group:nth-child(1) {
        display: flex;
    }

    button[onclick="showDocumentNumberFilterModal()"] {
        display: none !important;
    }

    /* ========== INVOICE TABLE ========== */
    #invoicesTableContainer {
        border-width: 0 !important;
        border-left-width: 0 !important;
        border-right-width: 0 !important;
        border-top-width: 0 !important;
        border-bottom-width: 0 !important;
    }

    .invoices-overflow {
            overflow-x: auto !important;
            padding-right: 0px !important;           
            padding-left: 0px!important;
            margin-bottom: 0px;
            border-width: 0 !important;
            border-left-width: 0 !important;
            border-right-width: 0 !important;
            border-top-width: 0 !important;
            border-bottom-width: 0 !important;
        }

    .invoices-table {
        width: 100%;
        min-width: auto;
        border-collapse: collapse;
        background: var(--surface-color);
        border: 1px solid var(--border-color);
        border-radius: 8px;
        overflow: hidden;
        font-size: 11px;
    }

    .invoices-table thead {
        background: var(--background-color);
        border-bottom: 2px solid var(--border-color);
        position: sticky;
        top: 0;
    }

    .invoices-table thead tr {
        display: table-row;
    }

    .invoices-table thead th {
        font-weight: 600;
        color: var(--text-secondary);
        font-size: 11px;
        padding: 8px 6px;
    }

    .invoices-table tbody tr {
        border-bottom: 1px solid var(--border-color);
    }

    .invoices-table tbody tr:last-child {
        display: none;
    }

    .invoices-table th,
    .invoices-table td {
        padding: 8px 6px;
        text-align: left;
        font-size: 11px;
        border: none;
    }

    /* Column 1: Checkbox - Hide */
    .invoices-table td:nth-child(1) {
        display: none;
    }

    .invoices-table th:nth-child(1) {
        display: none;
    }

    /* Columns 2-4, 6-7, 14-15: Hide */
    .invoices-table td:nth-child(2),
    .invoices-table td:nth-child(3),
    .invoices-table td:nth-child(4),
    .invoices-table td:nth-child(6),
    .invoices-table td:nth-child(7),
    .invoices-table td:nth-child(14),
    .invoices-table td:nth-child(15),
    .invoices-table th:nth-child(2),
    .invoices-table th:nth-child(3),
    .invoices-table th:nth-child(4),
    .invoices-table th:nth-child(6),
    .invoices-table th:nth-child(7),
    .invoices-table th:nth-child(14),
    .invoices-table th:nth-child(15) {
        display: none;
    }

    /* Column 5: Document # */
    .invoices-table th:nth-child(5),
    .invoices-table td:nth-child(5) {
        width: 20%;

    }

    /* Column 8: Due Date */
    .invoices-table th:nth-child(8),
    .invoices-table td:nth-child(8) {
        width: 10%;

    }
    

    /* Column 9: Arrears */
    .invoices-table th:nth-child(9),
    .invoices-table td:nth-child(9) {
        width: 10%;
        text-align: center;

    }

    /* Column 10: Local Amount */
    .invoices-table th:nth-child(10),
    .invoices-table td:nth-child(10) {
        width: 15%;
        text-align: right;
    }
    

    /* Column 11: Local Currency */
    .invoices-table th:nth-child(11),
    .invoices-table td:nth-child(11) {
        width: 10%;
        text-align: center;
    }

    /* Column 12: EUR Amount */
    .invoices-table th:nth-child(12)
    .invoices-table td:nth-child(12) {
        width: 15%;
        text-align: right;
    }

    /* Column 13: EUR Currency */
    .invoices-table td:nth-child(13),
    .invoices-table td:nth-child(13) {
        width: 10%;
        text-align: center;
    }
    

    .invoices-table td:nth-child(16),
    .invoices-table td:nth-child(16) {
        width: 10%;
        text-align: center;
    }
    
    .invoices-table td.currency {
        text-align: right;
    }

    .invoices-table td.currency.overdue-value {
        color: #dc2626;
    }

    .invoices-table td.currency.not-due-value {
        color: #16a34a;
    }

    /* ========== NOTES SECTION ========== */
    .notes-section {
        width: 100%;
        background: var(--surface-color);
        border: 0px solid var(--border-color);
        border-radius: 8px;
        border-left-width: 0px;
        border-right-width: 0px;
        border-top-width: 0px;
        border-bottom-width: 0px;
        padding-bottom: 5px;
        padding-left: 5px;
        padding-right: 5px;
        padding-top: 5px;
    }

    .notes-section h3 {
        font-size: 16px;
        margin: 0 0 16px 0;
        color: var(--text-primary);
    }

    .note-tabs,
    .note-buttons {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        margin-bottom: 16px;
    }

    .note-tabs button,
    .note-buttons button {
        min-height: 44px;
        padding: 8px 12px;
        font-size: 12px;
        font-weight: 500;
        background: var(--background-color);
        color: var(--text-primary);
        border: 1px solid var(--border-color);
        border-radius: 6px;
        cursor: pointer;
        transition: all 0.2s;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .note-tabs button:hover,
    .note-buttons button:hover {
        background: var(--hover-color);
        border-color: var(--primary-color);
        color: var(--primary-color);
    }

    .note-tabs button.active {
        background: var(--primary-color);
        color: white;
        border-color: var(--primary-color);
    }

    .note-item {
        padding: 12px;
        background: var(--hover-color);
        border-radius: 6px;
        border-left: 3px solid var(--primary-color);
        margin-bottom: 10px;
    }

    .note-item-header {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 12px;
        margin-bottom: 6px;
        font-size: 12px;
        color: var(--text-secondary);
    }
    
    .note-item-header-cell {
        display: flex;
        flex-direction: column;
        gap: 4px;
    }
    
    .note-item-header-label {
        font-size: 11px;
        color: var(--text-secondary);
        font-weight: 500;
    }
    
    .note-item-header-value {
        font-size: 12px;
        color: var(--text-primary);
        font-weight: 500;
    }

    .note-item-text {
        font-size: 13px;
        color: var(--text-primary);
        max-height: 150px;
        overflow-y: auto;
        word-wrap: break-word;
        word-break: break-word;
        padding-right: 4px;
    }
    
    .note-item-text::-webkit-scrollbar {
        width: 6px;
    }
    
    .note-item-text::-webkit-scrollbar-track {
        background: transparent;
    }
    
    .note-item-text::-webkit-scrollbar-thumb {
        background: var(--border-color);
        border-radius: 3px;
    }
    
    .note-item-text::-webkit-scrollbar-thumb:hover {
        background: var(--text-secondary);
    }

    /* ========== CONTACT SECTION ========== */
    .contact-section {
        width: 100%;
        background: var(--surface-color);
        border: 1px solid var(--border-color);
        border-radius: 8px;
        padding: 16px;
    }

    .contact-section h3 {
        font-size: 16px;
        margin: 0 0 16px 0;
        color: var(--text-primary);
    }

    /* ========== MODALS ========== */
    .role-modal,
    .detail-modal {
        padding: 0;
        align-items: flex-start;
    }

    .role-modal.visible,
    .detail-modal.visible {
        display: flex;
    }

    .role-modal-content,
    .detail-modal-content {
        max-width: none;
        width: 100%;
        height: 100%;
        border-radius: 0;
        padding: 16px 16px 80px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .role-modal-content h2,
    .detail-modal-content h2 {
        font-size: 20px;
        margin: 0 0 16px 0;
    }

    .role-options {
        display: flex;
        flex-direction: column;
        gap: 12px;
        margin-bottom: 20px;
    }

    .role-option {
        padding: 16px;
        border: 2px solid var(--border-color);
        border-radius: 8px;
        background: var(--surface-color);
        cursor: pointer;
        transition: all 0.2s;
        text-align: left;
        min-height: 44px;
        display: flex;
        align-items: center;
    }

    .role-option:active {
        border-color: var(--primary-color);
        background: var(--hover-color);
    }

    .role-option label {
        display: flex;
        align-items: center;
        cursor: pointer;
        margin: 0;
        font-weight: 500;
        width: 100%;
        gap: 12px;
    }

    .role-option input[type="radio"] {
        cursor: pointer;
        width: 20px;
        height: 20px;
        margin: 0;
    }

    .role-description {
        font-size: 12px;
        color: var(--text-secondary);
        margin-top: 4px;
        margin-left: 32px;
    }

    .role-submit-btn {
        width: 100%;
        min-height: 44px;
        padding: 12px 16px;
        background: var(--primary-color);
        color: white;
        border: none;
        border-radius: 6px;
        cursor: pointer;
        font-weight: 600;
        font-size: 14px;
        transition: all 0.2s;
    }


    .note-delete-btn {
        background: none;
        border: none;
        color: #dc2626;
        cursor: pointer;
        font-size: 13px;
        padding: 4 4px;
        transition: all 0.2s;
        align-content: flex-end;
        justify-content:: flex-end;
        text-align: right;
    }
    
    .note-delete-btn:active {
        color: #991b1b;
        opacity: 0.9;
    }

    .role-submit-btn:active:not(:disabled) {
        opacity: 0.9;
    }

    .role-submit-btn:disabled {
        opacity: 0.6;
        cursor: not-allowed;
    }

    .modal-close-btn {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        height: 44px;
        background: var(--surface-color);
        border-top: 1px solid var(--border-color);
        border-radius: 0;
        padding: 0;
    }

    /* ========== TYPOGRAPHY & SPACING ========== */
    h1 {
        font-size: 20px;
        font-weight: 700;
        margin: 0 0 16px 0;
    }

    h2 {
        font-size: 18px;
        font-weight: 700;
        margin: 0 0 12px 0;
    }

    h3 {
        font-size: 16px;
        font-weight: 600;
        margin: 0 0 12px 0;
    }

    /* ========== TOUCH TARGETS & INTERACTION ========== */
    button,
    input[type="button"],
    input[type="submit"],
    input[type="reset"],
    a.button {
        min-height: 33px;
        min-width: 44px;
        padding: 8px 16px;
        font-size: 16px;
        cursor: pointer;
        user-select: none;
        -webkit-user-select: none;
        -webkit-tap-highlight-color: transparent;
    }

    input,
    select,
    textarea {
        min-height: 44px;
        font-size: 16px;
        padding: 8px 12px;
        -webkit-appearance: none;
        appearance: none;
    }

    button:focus,
    input:focus,
    select:focus,
    textarea:focus {
        outline: 2px solid var(--primary-color);
        outline-offset: 2px;
    }

    /* ========== STATUS & PROGRESS ========== */
    .status-message {
        padding: 12px 16px;
        border-radius: 6px;
        font-size: 13px;
        margin-bottom: 16px;
    }

    .progress-indicator {
        padding: 16px;
        background-color: #f0f9ff;
        border: 1px solid #bae6fd;
        border-radius: 6px;
        margin-bottom: 16px;
        text-align: center;
    }

    .progress-indicator p {
        margin: 0;
        color: #0c4a6e;
        font-size: 13px;
        font-weight: 500;
    }

    /* ========== EMPTY STATE ========== */
    .empty-state {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: 40px 16px;
        text-align: center;
    }

    .empty-state h2 {
        font-size: 18px;
        margin: 0 0 8px 0;
        color: var(--text-secondary);
    }

    .empty-state p {
        font-size: 13px;
        color: var(--text-secondary);
        margin: 0;
    }

    /* ========== GENERAL RESPONSIVE FIXES ========== */
    table {
        border-collapse: collapse;
        width: 100%;
    }

    tr {
        border-bottom: 1px solid var(--border-color);
    }

    tbody tr {
        border: 1px solid var(--border-color);
    }

    /* Prevent text selection on long press */
    .controls-section,
    .pagination-controls {
        -webkit-user-select: none;
        user-select: none;
    }

    /* Fix for scrolling performance */
    .app-content {
        will-change: scroll-position;
    }

    /* Ensure all text is selectable when needed */
    td, th {
        -webkit-user-select: text;
        user-select: text;
    }

    /* ========== CONTACT SECTION ========== */
    .contact-dashboard-section {
        text-align: center !important;
        margin-top:0px !important;
        border: 0px solid #bae6fd !important;
        padding-bottom: 5px !important;
        padding-left: 5px !important;
        padding-right: 5px !important;
        padding-top: 5px !important;
    }

    .contact-dashboard-section > div:first-child {
        justify-content: center !important;
    }

    .log-contact-btn {
        margin: 0 auto !important;
    }

    /* ========== MODALS ========== */
    .contact-modal {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    #contactEditModal > div {
        width: 95% !important;
        max-width: 100% !important;
        max-height: 95vh !important;
        overflow-y: auto !important;
        padding: 16px !important;
        border-radius: 8px;
    }

    #contactEditModal h2 {
        font-size: 18px !important;
        margin-bottom: 16px !important;
    }

    #contactEditModal textarea {
        width: 100% !important;
        font-size: 14px !important;
        min-height: 80px !important;
    }

    /* Hide radio buttons, show dropdown select */
    #contactEditModal label[style*="display: flex; align-items: center"] {
        display: none !important;
    }

    #contactEditModal input[type="radio"] {
        display: none !important;
    }

    #contactEditModal #contactEditResponseSelect {
        display: block !important;
        width: 100% !important;
        min-height: 44px !important;
        font-size: 14px !important;
        padding: 10px 12px !important;
    }

    /* Optimize button layout for mobile */
    #contactEditModal > div > div:last-child {
        display: flex !important;
        flex-direction: column !important;
        gap: 12px !important;
        margin-top: 20px !important;
    }

    #contactEditModal > div > div:last-child > button:nth-child(1) {
        width: 100% !important;
        padding: 12px 16px !important;
        font-size: 14px !important;
        font-weight: 600 !important;
        border-radius: 6px !important;
        min-height: 44px !important;
        order: 3;
    }

    #contactEditModal > div > div:last-child > div {
        display: flex !important;
        flex-direction: column !important;
        gap: 12px !important;
        width: 100%;
        order: 2;
    }

    #contactEditModal > div > div:last-child > div > button {
        width: 100% !important;
        padding: 12px 16px !important;
        font-size: 14px !important;
        font-weight: 600 !important;
        border-radius: 6px !important;
        min-height: 44px !important;
    }

    /* Other modals responsive styling */
    #contactHistoryModal > div,
    #notesModal > div,
    #addnotesmodal > div {
        width: 95% !important;
        max-width: 100% !important;
        max-height: 90vh !important;
        padding: 16px !important;
    }

    #contactHistoryModal h2,
    #notesModal h2,
    #addnotesmodal h2 {
        font-size: 18px !important;
        margin-bottom: 16px !important;
    }

    #contactHistoryModal > div > div:last-child,
    #notesModal > div > div:last-child,
    #addnotesmodal > div > div:last-child {
        display: flex !important;
        flex-direction: column !important;
        gap: 12px !important;
        margin-top: 20px !important;
    }

    #contactHistoryModal button,
    #notesModal button,
    #addnotesmodal button {
        width: 100% !important;
        padding: 12px 16px !important;
        font-size: 14px !important;
        min-height: 44px !important;
        border-radius: 6px !important;
    }

    /* ========== ACCESSIBILITY ========== */
    a:focus,
    button:focus,
    input:focus,
    select:focus,
    textarea:focus {
        outline: 2px solid var(--primary-color);
        outline-offset: 2px;
    }

    /* High contrast mode support */
    @media (prefers-contrast: more) {
        .app-header {
            border-bottom-width: 2px;
        }
        .clients-table tbody tr,
        .detail-header {
            border-width: 2px;
        }
    }

    /* Reduced motion support */
    @media (prefers-reduced-motion: reduce) {
        * {
            animation-duration: 0.01ms !important;
            animation-iteration-count: 1 !important;
            transition-duration: 0.01ms !important;
        }
    }

    /* Blocked Orders Table Mobile (Under 600px) */
    #blockedOrdersTableContainer .clients-table th:nth-child(1),
    #blockedOrdersTableContainer .clients-table td:nth-child(1),
    #blockedOrdersTableContainer .clients-table th:nth-child(2),
    #blockedOrdersTableContainer .clients-table td:nth-child(2),
    #blockedOrdersTableContainer .clients-table th:nth-child(5),
    #blockedOrdersTableContainer .clients-table td:nth-child(5) {
        display: none !important;
    }

    /* Column widths for mobile */
    #blockedOrdersTableContainer .clients-table th:nth-child(3),
    #blockedOrdersTableContainer .clients-table td:nth-child(3) { text-align: center;display: table-cell !important; width: 20% !important; font-size:10px; }
    #blockedOrdersTableContainer .clients-table th:nth-child(4),
    #blockedOrdersTableContainer .clients-table td:nth-child(4) { text-align: center;display: table-cell !important; width: 20% !important; font-size: 10px; }
    #blockedOrdersTableContainer .clients-table th:nth-child(6),
    #blockedOrdersTableContainer .clients-table td:nth-child(6) { text-align: center;display: table-cell !important; width: 10% !important; font-size: 10px; }
    #blockedOrdersTableContainer .clients-table th:nth-child(7),
    #blockedOrdersTableContainer .clients-table td:nth-child(7) { text-align: center;display: table-cell !important; width: 10% !important; font-size: 10px; }
    #blockedOrdersTableContainer .clients-table th:nth-child(8),
    #blockedOrdersTableContainer .clients-table td:nth-child(8) { text-align: left;display: table-cell !important; width: 10% !important; font-size: 10px; }
}

@media (min-width: 601px) and (max-width: 900px) {
    /* ========== RESPONSIVE RESET ========== */
    .login-modal {
        display: flex !important;
    }

    .login-modal.hidden {
        display: none !important;
    }

    .role-modal {
        display: none !important;
    }

    .role-modal.visible {
        display: flex !important;
    }

    .detail-modal {
        display: none !important;
    }

    .detail-modal.visible {
        display: flex !important;
    }

    #app {
        display: none !important;
    }

    #app.visible {
        display: flex !important;
    }

    #addnotesmodal {
        display: none !important;
    }

    #addnotesmodal[style*="display: flex"],
    #addnotesmodal[style*="display: flex;"] {
        display: flex !important;
    }
    
    #backToListBtn {
            max-height: 33px !important;
            padding: 0 12px;
            font-size: 13px;
            font-weight: 500;
            min-width: 44px;
            flex-shrink: 0; 
            
    }
       .back-to-list-btn {
         max-height: 33px !important;
            padding: 0 12px;
            font-size: 13px;
            font-weight: 500;
            min-width: 44px;
            flex-shrink: 0;   
       }
    .contact-modal {
        display: none !important;
    }

    .contact-modal[style*="display: flex"],
    .contact-modal[style*="display: flex;"] {
        display: flex !important;
    }

    #notesModal {
        display: none !important;
    }

    #notesModal.visible {
        display: flex !important;
    }

    #notesModal[style*="display: flex"],
    #notesModal[style*="display: flex;"] {
        display: flex !important;
    }

    #noteDetailsModal {
        display: none !important;
    }

    #noteDetailsModal[style*="display: flex"],
    #noteDetailsModal[style*="display: flex;"] {
        display: flex !important;
    }

    #contactLogModal {
        display: none !important;
    }

    #contactLogModal[style*="display: flex"],
    #contactLogModal[style*="display: flex;"] {
        display: flex !important;
    }

    #contactEditModal {
        display: none !important;
    }

    #contactEditModal[style*="display: flex"],
    #contactEditModal[style*="display: flex;"] {
        display: flex !important;
    }

    #contactDetailsModal {
        display: none !important;
    }

    #contactDetailsModal[style*="display: flex"],
    #contactDetailsModal[style*="display: flex;"] {
        display: flex !important;
    }

    #contactHistoryModal {
        display: none !important;
    }

    #contactHistoryModal[style*="display: flex"],
    #contactHistoryModal[style*="display: flex;"] {
        display: flex !important;
    }

    #documentNumberFilterModal {
        display: none !important;
    }

    #documentNumberFilterModal[style*="display: flex"],
    #documentNumberFilterModal[style*="display: flex;"] {
        display: flex !important;
    }

    #reasonCodeModal {
        display: none !important;
    }

    #reasonCodeModal.visible {
        display: flex !important;
    }

    #reasonCodeAgingModal {
        display: none !important;
    }

    #reasonCodeAgingModal.visible {
        display: flex !important;
    }

    * {
        -webkit-text-size-adjust: 100%;
        -moz-text-size-adjust: 100%;
    }

    html {
        height: 100%;
        overflow-y: auto;
    }

    body {
        font-size: 14px;
        line-height: 1.5;
        overflow-x: hidden !important;
        width: 100%;
    }

    /* ========== HEADER ADAPTATION ========== */
    .app-header {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        height: 64px;
        padding: 0 16px;
        gap: 12px;
        z-index: 100;
        display: flex;
        align-items: center;
        flex-wrap: nowrap;
    }

    .app-title {
        font-size: 18px;
        font-weight: 700;
        white-space: nowrap;
    }


   .adminPanel-btn{
        display: none !important;
    }
    
    .uploadMarketData-btn {
        display: none !important;
    }
    
    

    .app-header-spacer {
        flex: 1;
    }

    /* ========== APP CONTENT ========== */
    .app-content {
        margin-top: 64px;
        padding: 5px !important;
        height: calc(100vh - 64px);
        overflow-y: auto !important;
        overflow-x: hidden !important;
        -webkit-overflow-scrolling: touch;
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
        gap: 5px !important;
    }

    /* ========== APP LOBBY LAYOUT (EXPANDABLE CARDS) ========== */
    .apps-container {
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
        height: 100% !important;
    }

    .app-panel {
        flex: none !important;
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
        border: none !important;
        border-right: none !important;
        background: transparent !important;
        justify-content: flex-start !important;
        align-items: stretch !important;
    }

    .app-panel::before {
        display: none !important;
    }

    .app-panel.left,
    .app-panel.center,
    .app-panel.right {
        border: none !important;
        border-right: none !important;
        background: transparent !important;
    }

    .app-panel.left,
    .app-panel.right {
        display: none !important;
    }

    .app-panel-content {
        display: flex !important;
        flex-direction: column !important;
        align-items: stretch !important;
        width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    .app-panel-content:hover {
        transform: none !important;
    }

    .app-panel:hover .app-panel-content {
        transform: none !important;
    }

    .app-card {
        width: 100% !important;
        max-width: none !important;
        padding: 16px !important;
        margin: 0 !important;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08) !important;
        border: 1px solid var(--border-color) !important;
        background: var(--surface-color) !important;
        min-height: auto !important;
        box-sizing: border-box !important;
    }

    .app-name {
        font-size: 18px !important;
        margin: 0 0 12px 0 !important;
        padding: 0 !important;
    }

    .app-description {
        font-size: 13px !important;
        margin: 12px 0 0 0 !important;
        line-height: 1.4 !important;
    }

    .app-features {
        font-size: 12px !important;
        margin: 12px 0 0 0 !important;
    }

    .app-features li {
        font-size: 12px !important;
    }

    .app-button {
        width: 100% !important;
        padding: 10px 12px !important;
        font-size: 14px !important;
        margin-top: 12px !important;
        cursor: pointer !important;
    }

    .app-panel:hover .app-card {
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08) !important;
        border-color: var(--border-color) !important;
    }



    /* ========== CONTROLS SECTION ========== */
    .controls-section {
        display: flex;
        flex-direction: column;
        gap: 12px;
        margin-bottom: 20px;
    }

    .control-group {
        width: 100%;
        display: flex;
        flex-direction: column;
        gap: 6px;
    }

    .control-group label {
        font-size: 13px;
        font-weight: 600;
        color: var(--text-secondary);
    }

    .market-selector,
    .search-input {
        width: 100%;
        min-height: 44px;
        padding: 12px 12px;
        font-size: 16px;
        border: 1px solid var(--border-color);
        border-radius: 6px;
        background: var(--surface-color);
        color: var(--text-primary);
        -webkit-appearance: none;
        appearance: none;
    }

    .market-selector:focus,
    .search-input:focus {
        outline: none;
        border-color: var(--primary-color);
        box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
    }

    .segment-checkboxes-container2 {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 8px !important;
        padding: 10px !important;
        background: var(--surface-color) !important;
        border: 1px solid var(--border-color) !important;
        border-radius: 6px !important;
        width: 100% !important;
    }

    .division-checkboxes-container {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 8px !important;
        padding: 10px !important;
        background: var(--surface-color) !important;
        border: 1px solid var(--border-color) !important;
        border-radius: 6px !important;
        width: 100% !important;
    }

    .segment-checkbox-item2 {
        display: flex !important;
        align-items: center !important;
        gap: 8px !important;
        font-size: 14px !important;
        padding: 4px 0 !important;
    }

    .division-checkbox-item {
        display: flex !important;
        align-items: center !important;
        gap: 8px !important;
        font-size: 14px !important;
        padding: 4px 0 !important;
    }

    .segment-checkbox-item2 input[type="checkbox"] {
        width: 18px !important;
        height: 18px !important;
        margin: 0 !important;
    }

    .division-checkbox-item input[type="checkbox"] {
        width: 18px !important;
        height: 18px !important;
        margin: 0 !important;
    }

    .hidden {
        display: none !important;
    }

    /* ========== CLIENT LIST - TABLE VIEW ========== */

    
    #clientsContainer {
        overflow-x: visible !important;
    }

    .clients-table {
        width: 100% !important;
        max-width: 100% !important;
        min-width: auto !important;
        border-collapse: collapse;
        background: var(--surface-color);
        border: 1px solid var(--border-color);
        border-radius: 8px;
        overflow: hidden;
        font-size: 12px;
    }

    .clients-table thead {
        display: table-header-group;
        background: var(--background-color);
        border-bottom: 2px solid var(--border-color);
    }

    .clients-table thead tr {
        display: table-row;
    }

    .clients-table thead th {
        font-weight: 600;
        color: var(--text-secondary);
        font-size: 11px;
        padding: 8px 6px;
        text-align: left;
        border: none;
    }

    .clients-table tbody {
        display: table-row-group;
    }

    .clients-table tbody tr {
        display: table-row;
        border-bottom: 1px solid var(--border-color);
        cursor: pointer;
        transition: background-color 0.2s;
    }

    .clients-table tbody tr:hover {
        background-color: var(--hover-color);
    }

    .clients-table td {
        padding: 8px 6px;
        font-size: 12px;
        border: none;
        white-space: normal;
        word-wrap: break-word;
    }

    /* Show only Market (1), Customer Name (3), Total Overdue (10) */
    .clients-table td:nth-child(1) {
        width: 20%;
        font-weight: 600;
        color: var(--text-secondary);
        font-size: 11px;
    }

    .clients-table td:nth-child(3) {
        width: 50%;
        font-weight: 600;
        color: var(--text-primary);
        font-size: 12px;
    }

    .clients-table td:nth-child(10) {
        width: 30%;
        text-align: right;
        font-weight: 600;
        color: var(--text-primary);
    }

    /* Hide Account Number (2), columns 4-9, 11-12 */
    .clients-table td:nth-child(4),
    .clients-table td:nth-child(5),
    .clients-table td:nth-child(6),
    .clients-table td:nth-child(7),
    .clients-table td:nth-child(8),
    .clients-table td:nth-child(9),
    .clients-table td:nth-child(11),
    .clients-table td:nth-child(12),
    .clients-table th:nth-child(4),
    .clients-table th:nth-child(5),
    .clients-table th:nth-child(6),
    .clients-table th:nth-child(7),
    .clients-table th:nth-child(8),
    .clients-table th:nth-child(9),
    .clients-table th:nth-child(11),
    .clients-table th:nth-child(12) {
        display: none;
    }

    .clients-table td.currency {
        text-align: right;
        font-family: 'Courier New', monospace;
        font-weight: 500;
    }

    .clients-table td.total-overdue-value {
        color: #dc2626;
        font-weight: 700;
        font-size: 13px;
    }

    .clients-table td.highlight-overdue {
        background-color: transparent;
    }

    .clients-table tbody tr:hover td.highlight-overdue {
        background-color: transparent;
    }

    /* ========== PAGINATION ========== */
    .pagination-controls {
        display: none;
        gap: 12px;
        align-items: center;
        justify-content: center;
        margin-top: 20px;
        padding: 16px;
        background-color: var(--background-color);
        border-radius: 6px;
        flex-wrap: wrap;
    }

    .pagination-controls.visible {
        display: flex;
    }

    .pagination-btn {
        padding: 8px 12px;
        background: var(--surface-color);
        color: var(--text-primary);
        border: 1px solid var(--border-color);
        border-radius: 6px;
        cursor: pointer;
        font-size: 13px;
        font-weight: 500;
        min-height: 40px;
        transition: all 0.2s;
    }

    .pagination-btn:hover:not(:disabled) {
        background: var(--hover-color);
        border-color: var(--primary-color);
        color: var(--primary-color);
    }

    .pagination-btn:disabled {
        opacity: 0.5;
        cursor: not-allowed;
    }

    .page-indicator {
        font-size: 13px;
        color: var(--text-secondary);
        font-weight: 600;
        min-width: 100px;
        text-align: center;
    }

    /* ========== DETAIL VIEW LAYOUT ========== */
    .detail-header {
        background: var(--surface-color);
        border: 1px solid var(--border-color);
        border-radius: 8px;
        padding: 16px;
        margin-bottom: 20px;
    }

    .detail-header-info h2 {
        font-size: 18px;
        margin: 0 0 12px 0;
        color: var(--text-primary);
    }

    .detail-header-row {
        display: flex;
        flex-direction: column;
        gap: 8px;
        font-size: 12px;
        line-height: 1.4;
    }

    .detail-header-row span {
        white-space: normal;
        word-break: break-word;
    }

    .detail-header-row strong {
        color: var(--text-secondary);
        font-weight: 600;
    }

    .total-overdue-value {
        color: #dc2626;
        font-weight: 700;
    }

    .detail-content {
        display: flex;
        flex-direction: column;
        gap: 20px;
    }

    .detail-main {
        width: 100%;
        order: 1;
    }

    .detail-main h3 {
        font-size: 16px;
        margin: 0 0 16px 0;
        color: var(--text-primary);
    }

    .detail-sidebar {
        width: 100%;
        order: 2;
        display: flex;
        flex-direction: column;
        gap: 20px;
        padding-left: 5px;
        padding-top: 5px;
        padding-right: 5px;
        padding-bottom: 5px;
    }

    /* ========== INVOICE FILTERS ========== */
    .invoice-filters {
        display: flex;
        flex-direction: column;
        gap: 0px !important;
        margin-bottom: 0px !important;
        border: 0px !important;
        padding: 0px !important;
        background: #f8fafc  !important;
    }

    .invoice-filters .filter-group {
        display: flex;
        gap: 8px;
        align-items: center;
        flex-wrap: wrap;
    }

    .invoice-filters .filter-group label {
        font-weight: 600;
        font-size: 12px;
        white-space: nowrap;
    }

    .invoice-filters .filter-group select,
    .invoice-filters .filter-group button {
        min-height: 36px;
        font-size: 12px;
    }

    /* Hide non-essential filters on mobile */
    .invoice-filters .filter-group:nth-child(2),
    .invoice-filters .filter-group:nth-child(3),
    .invoice-filters .filter-group:nth-child(4),
    .invoice-filters .filter-group:nth-child(5) {
        display: none;
    }

    /* Show only first filter group (Status) and selected invoices summary if present */
    .invoice-filters .filter-group:nth-child(1) {
        display: flex;
    }

    button[onclick="showDocumentNumberFilterModal()"] {
        display: none !important;
    }

    /* ========== INVOICE TABLE ========== */
    #invoicesTableContainer {
        border-width: 0 !important;
        border-left-width: 0 !important;
        border-right-width: 0 !important;
        border-top-width: 0 !important;
        border-bottom-width: 0 !important;
    }

    .invoices-overflow {
            overflow-x: auto !important;
            padding-right: 5px !important;           
            padding-left: 5px!important;
            margin-bottom: 0px;
            border-width: 0 !important;
            border-left-width: 0 !important;
            border-right-width: 0 !important;
            border-top-width: 0 !important;
            border-bottom-width: 0 !important;
        }

    .invoices-table {
        width: 100%;
        min-width: auto;
        border-collapse: collapse;
        background: var(--surface-color);
        border: 1px solid var(--border-color);
        border-radius: 8px;
        overflow: hidden;
        font-size: 11px;
    }

    .invoices-table thead {
        background: var(--background-color);
        border-bottom: 2px solid var(--border-color);
        position: sticky;
        top: 0;
    }

    .invoices-table thead tr {
        display: table-row;
    }

    .invoices-table thead th {
        font-weight: 600;
        color: var(--text-secondary);
        font-size: 11px;
        padding: 8px 6px;
    }

    .invoices-table tbody tr {
        border-bottom: 1px solid var(--border-color);
    }

    .invoices-table tbody tr:last-child {
        display: none;
    }

    .invoices-table th,
    .invoices-table td {
        padding: 8px 6px;
        text-align: left;
        font-size: 11px;
        border: none;
    }

    /* Column 1: Checkbox - Hide */
    .invoices-table td:nth-child(1) {
        display: none;
    }

    .invoices-table th:nth-child(1) {
        display: none;
    }

    /* Columns 2-4, 6-7, 14-15: Hide */
    .invoices-table td:nth-child(2),
    .invoices-table td:nth-child(3),
    .invoices-table td:nth-child(4),
    .invoices-table td:nth-child(6),
    .invoices-table td:nth-child(7),
    .invoices-table td:nth-child(14),
    .invoices-table td:nth-child(15),
    .invoices-table th:nth-child(2),
    .invoices-table th:nth-child(3),
    .invoices-table th:nth-child(4),
    .invoices-table th:nth-child(6),
    .invoices-table th:nth-child(7),
    .invoices-table th:nth-child(14),
    .invoices-table th:nth-child(15) {
        display: none;
    }

    /* Column 5: Document # */
    .invoices-table th:nth-child(5),
    .invoices-table td:nth-child(5) {
        width: 20%;

    }

    /* Column 8: Due Date */
    .invoices-table th:nth-child(8),
    .invoices-table td:nth-child(8) {
        width: 10%;

    }
    

    /* Column 9: Arrears */
    .invoices-table th:nth-child(9),
    .invoices-table td:nth-child(9) {
        width: 10%;
        text-align: center;

    }

    /* Column 10: Local Amount */
    .invoices-table th:nth-child(10),
    .invoices-table td:nth-child(10) {
        width: 15%;
        text-align: right;
    }
    

    /* Column 11: Local Currency */
    .invoices-table th:nth-child(11),
    .invoices-table td:nth-child(11) {
        width: 10%;
        text-align: center;
    }

    /* Column 12: EUR Amount */
    .invoices-table th:nth-child(12)
    .invoices-table td:nth-child(12) {
        width: 15%;
        text-align: right;
    }

    /* Column 13: EUR Currency */
    .invoices-table td:nth-child(13),
    .invoices-table td:nth-child(13) {
        width: 10%;
        text-align: center;
    }
    

    .invoices-table td:nth-child(16),
    .invoices-table td:nth-child(16) {
        width: 10%;
        text-align: center;
    }

    .invoices-table td.currency {
        text-align: right;
    }

    .invoices-table td.currency.overdue-value {
        color: #dc2626;
    }

    .invoices-table td.currency.not-due-value {
        color: #16a34a;
    }

    /* ========== NOTES SECTION ========== */
    .notes-section {
        width: 100%;
        background: var(--surface-color);
        border: 0px solid var(--border-color);
        border-radius: 8px;
        border-left-width: 0px;
        border-right-width: 0px;
        border-top-width: 0px;
        border-bottom-width: 0px;
        padding-bottom: 5px;
        padding-left: 5px;
        padding-right: 5px;
        padding-top: 5px;
    }

    .notes-section h3 {
        font-size: 16px;
        margin: 0 0 16px 0;
        color: var(--text-primary);
    }

    .note-tabs,
    .note-buttons {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        margin-bottom: 16px;
    }

    .note-tabs button,
    .note-buttons button {
        min-height: 44px;
        padding: 8px 12px;
        font-size: 12px;
        font-weight: 500;
        background: var(--background-color);
        color: var(--text-primary);
        border: 1px solid var(--border-color);
        border-radius: 6px;
        cursor: pointer;
        transition: all 0.2s;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .note-tabs button:hover,
    .note-buttons button:hover {
        background: var(--hover-color);
        border-color: var(--primary-color);
        color: var(--primary-color);
    }

    .note-tabs button.active {
        background: var(--primary-color);
        color: white;
        border-color: var(--primary-color);
    }

    .note-item {
        padding: 12px;
        background: var(--hover-color);
        border-radius: 6px;
        border-left: 3px solid var(--primary-color);
        margin-bottom: 10px;
    }

    .note-item-header {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 12px;
        margin-bottom: 6px;
        font-size: 12px;
        color: var(--text-secondary);
    }
    
    .note-item-header-cell {
        display: flex;
        flex-direction: column;
        gap: 4px;
    }
    
    .note-item-header-label {
        font-size: 11px;
        color: var(--text-secondary);
        font-weight: 500;
    }
    
    .note-item-header-value {
        font-size: 12px;
        color: var(--text-primary);
        font-weight: 500;
    }

    .note-item-text {
        font-size: 13px;
        color: var(--text-primary);
        max-height: 150px;
        overflow-y: auto;
        word-wrap: break-word;
        word-break: break-word;
        padding-right: 4px;
    }
    
    .note-item-text::-webkit-scrollbar {
        width: 6px;
    }
    
    .note-item-text::-webkit-scrollbar-track {
        background: transparent;
    }
    
    .note-item-text::-webkit-scrollbar-thumb {
        background: var(--border-color);
        border-radius: 3px;
    }
    
    .note-item-text::-webkit-scrollbar-thumb:hover {
        background: var(--text-secondary);
    }

    /* ========== CONTACT SECTION ========== */
    .contact-section {
        width: 100%;
        background: var(--surface-color);
        border: 1px solid var(--border-color);
        border-radius: 8px;
        padding: 16px;
    }

    .contact-section h3 {
        font-size: 16px;
        margin: 0 0 16px 0;
        color: var(--text-primary);
    }

    /* ========== MODALS ========== */
    .role-modal,
    .detail-modal {
        padding: 0;
        align-items: flex-start;
    }

    .role-modal.visible,
    .detail-modal.visible {
        display: flex;
    }

    .role-modal-content,
    .detail-modal-content {
        max-width: none;
        width: 100%;
        height: 100%;
        border-radius: 0;
        padding: 16px 16px 80px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .role-modal-content h2,
    .detail-modal-content h2 {
        font-size: 20px;
        margin: 0 0 16px 0;
    }

    .role-options {
        display: flex;
        flex-direction: column;
        gap: 12px;
        margin-bottom: 20px;
    }

    .role-option {
        padding: 16px;
        border: 2px solid var(--border-color);
        border-radius: 8px;
        background: var(--surface-color);
        cursor: pointer;
        transition: all 0.2s;
        text-align: left;
        min-height: 44px;
        display: flex;
        align-items: center;
    }

    .role-option:active {
        border-color: var(--primary-color);
        background: var(--hover-color);
    }

    .role-option label {
        display: flex;
        align-items: center;
        cursor: pointer;
        margin: 0;
        font-weight: 500;
        width: 100%;
        gap: 12px;
    }

    .role-option input[type="radio"] {
        cursor: pointer;
        width: 20px;
        height: 20px;
        margin: 0;
    }

    .role-description {
        font-size: 12px;
        color: var(--text-secondary);
        margin-top: 4px;
        margin-left: 32px;
    }

    .role-submit-btn {
        width: 100%;
        min-height: 44px;
        padding: 12px 16px;
        background: var(--primary-color);
        color: white;
        border: none;
        border-radius: 6px;
        cursor: pointer;
        font-weight: 600;
        font-size: 14px;
        transition: all 0.2s;
    }


    .note-delete-btn {
        background: none;
        border: none;
        color: #dc2626;
        cursor: pointer;
        font-size: 13px;
        padding: 4 4px;
        transition: all 0.2s;
        align-content: flex-end;
        justify-content:: flex-end;
        text-align: right;
    }
    
    .note-delete-btn:active {
        color: #991b1b;
        opacity: 0.9;
    }

    .role-submit-btn:active:not(:disabled) {
        opacity: 0.9;
    }

    .role-submit-btn:disabled {
        opacity: 0.6;
        cursor: not-allowed;
    }

    .modal-close-btn {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        height: 44px;
        background: var(--surface-color);
        border-top: 1px solid var(--border-color);
        border-radius: 0;
        padding: 0;
    }

    /* ========== TYPOGRAPHY & SPACING ========== */
    h1 {
        font-size: 20px;
        font-weight: 700;
        margin: 0 0 16px 0;
    }

    h2 {
        font-size: 18px;
        font-weight: 700;
        margin: 0 0 12px 0;
    }

    h3 {
        font-size: 16px;
        font-weight: 600;
        margin: 0 0 12px 0;
    }

    /* ========== TOUCH TARGETS & INTERACTION ========== */
    button,
    input[type="button"],
    input[type="submit"],
    input[type="reset"],
    a.button {
        min-height: 33px;
        min-width: 44px;
        padding: 8px 16px;
        font-size: 16px;
        cursor: pointer;
        user-select: none;
        -webkit-user-select: none;
        -webkit-tap-highlight-color: transparent;
    }

    input,
    select,
    textarea {
        min-height: 44px;
        font-size: 16px;
        padding: 8px 12px;
        -webkit-appearance: none;
        appearance: none;
    }

    button:focus,
    input:focus,
    select:focus,
    textarea:focus {
        outline: 2px solid var(--primary-color);
        outline-offset: 2px;
    }

    /* ========== STATUS & PROGRESS ========== */
    .status-message {
        padding: 12px 16px;
        border-radius: 6px;
        font-size: 13px;
        margin-bottom: 16px;
    }

    .progress-indicator {
        padding: 16px;
        background-color: #f0f9ff;
        border: 1px solid #bae6fd;
        border-radius: 6px;
        margin-bottom: 16px;
        text-align: center;
    }

    .progress-indicator p {
        margin: 0;
        color: #0c4a6e;
        font-size: 13px;
        font-weight: 500;
    }

    /* ========== EMPTY STATE ========== */
    .empty-state {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: 40px 16px;
        text-align: center;
    }

    .empty-state h2 {
        font-size: 18px;
        margin: 0 0 8px 0;
        color: var(--text-secondary);
    }

    .empty-state p {
        font-size: 13px;
        color: var(--text-secondary);
        margin: 0;
    }

    /* ========== GENERAL RESPONSIVE FIXES ========== */
    table {
        border-collapse: collapse;
        width: 100%;
    }

    tr {
        border-bottom: 1px solid var(--border-color);
    }

    tbody tr {
        border: 1px solid var(--border-color);
    }

    /* Prevent text selection on long press */
    .controls-section,
    .pagination-controls {
        -webkit-user-select: none;
        user-select: none;
    }

    /* Fix for scrolling performance */
    .app-content {
        will-change: scroll-position;
    }

    /* Ensure all text is selectable when needed */
    td, th {
        -webkit-user-select: text;
        user-select: text;
    }

    /* ========== CONTACT SECTION ========== */
    .contact-dashboard-section {
        text-align: center !important;
        margin-top:0px !important;
        border: 0px solid #bae6fd !important;
        padding-bottom: 5px !important;
        padding-left: 5px !important;
        padding-right: 5px !important;
        padding-top: 5px !important;
    }

    .contact-dashboard-section > div:first-child {
        justify-content: center !important;
    }

    .log-contact-btn {
        margin: 0 auto !important;
    }

    /* ========== MODALS ========== */
    .contact-modal {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    #contactEditModal > div {
        width: 95% !important;
        max-width: 100% !important;
        max-height: 95vh !important;
        overflow-y: auto !important;
        padding: 16px !important;
        border-radius: 8px;
    }

    #contactEditModal h2 {
        font-size: 18px !important;
        margin-bottom: 16px !important;
    }

    #contactEditModal textarea {
        width: 100% !important;
        font-size: 14px !important;
        min-height: 80px !important;
    }

    /* Hide radio buttons, show dropdown select */
    #contactEditModal label[style*="display: flex; align-items: center"] {
        display: none !important;
    }

    #contactEditModal input[type="radio"] {
        display: none !important;
    }

    #contactEditModal #contactEditResponseSelect {
        display: block !important;
        width: 100% !important;
        min-height: 44px !important;
        font-size: 14px !important;
        padding: 10px 12px !important;
    }

    /* Optimize button layout for mobile */
    #contactEditModal > div > div:last-child {
        display: flex !important;
        flex-direction: column !important;
        gap: 12px !important;
        margin-top: 20px !important;
    }

    #contactEditModal > div > div:last-child > button:nth-child(1) {
        width: 100% !important;
        padding: 12px 16px !important;
        font-size: 14px !important;
        font-weight: 600 !important;
        border-radius: 6px !important;
        min-height: 44px !important;
        order: 3;
    }

    #contactEditModal > div > div:last-child > div {
        display: flex !important;
        flex-direction: column !important;
        gap: 12px !important;
        width: 100%;
        order: 2;
    }

    #contactEditModal > div > div:last-child > div > button {
        width: 100% !important;
        padding: 12px 16px !important;
        font-size: 14px !important;
        font-weight: 600 !important;
        border-radius: 6px !important;
        min-height: 44px !important;
    }

    /* Other modals responsive styling */
    #contactHistoryModal > div,
    #notesModal > div,
    #addnotesmodal > div {
        width: 95% !important;
        max-width: 100% !important;
        max-height: 90vh !important;
        padding: 16px !important;
    }

    #contactHistoryModal h2,
    #notesModal h2,
    #addnotesmodal h2 {
        font-size: 18px !important;
        margin-bottom: 16px !important;
    }

    #contactHistoryModal > div > div:last-child,
    #notesModal > div > div:last-child,
    #addnotesmodal > div > div:last-child {
        display: flex !important;
        flex-direction: column !important;
        gap: 12px !important;
        margin-top: 20px !important;
    }

    #contactHistoryModal button,
    #notesModal button,
    #addnotesmodal button {
        width: 100% !important;
        padding: 12px 16px !important;
        font-size: 14px !important;
        min-height: 44px !important;
        border-radius: 6px !important;
    }

    /* ========== ACCESSIBILITY ========== */
    a:focus,
    button:focus,
    input:focus,
    select:focus,
    textarea:focus {
        outline: 2px solid var(--primary-color);
        outline-offset: 2px;
    }

    /* High contrast mode support */
    @media (prefers-contrast: more) {
        .app-header {
            border-bottom-width: 2px;
        }
        .clients-table tbody tr,
        .detail-header {
            border-width: 2px;
        }
    }

    /* Reduced motion support */
    @media (prefers-reduced-motion: reduce) {
        * {
            animation-duration: 0.01ms !important;
            animation-iteration-count: 1 !important;
            transition-duration: 0.01ms !important;
        }
    }

    /* Blocked Orders Table Tablet (601px - 900px) */
    #blockedOrdersTableContainer .clients-table th:nth-child(1),
    #blockedOrdersTableContainer .clients-table td:nth-child(1) {
        display: none !important;
    }
    
    #blockedOrdersTableContainer .clients-table th:nth-child(2),
    #blockedOrdersTableContainer .clients-table td:nth-child(2) { text-align: center;display: table-cell !important; width: 10% !important; font-size: 11px; }
    #blockedOrdersTableContainer .clients-table th:nth-child(3),
    #blockedOrdersTableContainer .clients-table td:nth-child(3) { text-align: center;display: table-cell !important; width: 30% !important; font-size: 11px; }
    #blockedOrdersTableContainer .clients-table th:nth-child(4),
    #blockedOrdersTableContainer .clients-table td:nth-child(4) { text-align: center;display: table-cell !important; width: 30% !important; font-size: 11px; }
    #blockedOrdersTableContainer .clients-table th:nth-child(5),
    #blockedOrdersTableContainer .clients-table td:nth-child(5) { text-align: center;display: table-cell !important; width: 10% !important; font-size: 11px; }
    #blockedOrdersTableContainer .clients-table th:nth-child(6),
    #blockedOrdersTableContainer .clients-table td:nth-child(6) { text-align: center;display: table-cell !important; width: 7% !important; font-size: 11px; }
    #blockedOrdersTableContainer .clients-table th:nth-child(7),
    #blockedOrdersTableContainer .clients-table td:nth-child(7) { text-align: center;display: table-cell !important; width: 7% !important; font-size: 11px; }
    #blockedOrdersTableContainer .clients-table th:nth-child(8),
    #blockedOrdersTableContainer .clients-table td:nth-child(8) { text-align: center;display: table-cell !important; width: 5% !important; font-size: 11px; }
}
