.af-portal-wrapper {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    direction: rtl;
    max-width: 100%;
    box-sizing: border-box;
}

/* Header & Meta */
.af-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 2px solid #eee; padding-bottom: 15px; margin-bottom: 20px; flex-wrap: wrap; gap: 10px; }
.af-header h2 { margin: 0; font-size: 20px; color: #333; }
.header-meta { display: flex; align-items: center; gap: 10px; }
.count-badge { background: #e7f1ff; color: #0c63e4; padding: 4px 10px; border-radius: 15px; font-weight: bold; font-size: 13px; white-space: nowrap; }
.mode-badge { font-size: 12px; background: #eee; padding: 3px 8px; border-radius: 4px; color: #666; white-space: nowrap; }

/* Filters */
.af-portal-filter { display: flex; gap: 15px; flex-wrap: wrap; background: #f8f9fa; padding: 15px; border-radius: 6px; margin-bottom: 20px; align-items: flex-end; }
.filter-item { flex: 1 1 200px; min-width: 140px; }
.filter-item label { display: block; font-size: 12px; font-weight: bold; margin-bottom: 5px; color: #555; }
.filter-item select, .filter-item input { width: 100%; height: 38px; border: 1px solid #ddd; border-radius: 4px; padding: 0 10px; box-sizing: border-box; }
.reset-btn { color: #dc3545; text-decoration: none; font-size: 13px; padding-bottom: 10px; display: inline-block; }

/* Table Base */
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.af-portal-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 1100px; }

/* --- CENTER ALIGNMENT --- */
.af-portal-table th { 
    background: #f1f3f5; 
    color: #495057; 
    font-weight: 700; 
    padding: 12px 8px; 
    text-align: center; /* Centered Header */
    border-bottom: 2px solid #dee2e6; 
    white-space: nowrap; 
}
.af-portal-table td { 
    padding: 10px 8px; 
    border-bottom: 1px solid #eee; 
    vertical-align: middle; 
    color: #333;
    text-align: center; /* Centered Data */
}

/* --- COLUMN SIZING --- */
.col-id, .col-date, .col-time, .col-phone, .col-pay, .col-type, .col-pdf { white-space: nowrap; }

/* Name Column */
.col-name { min-width: 190px; font-weight: 600; }

/* Address Columns (From/To) */
.col-addr { min-width: 135px; line-height: 1.35; font-size: 12.5px; }

/* Status Column */
.col-status { width: 100px; min-width: 100px; }

/* Other Fixed Widths */
.col-id { width: 50px; }
.col-pdf { width: 50px; }
.col-date { min-width: 85px; }
.col-time { min-width: 60px; }

/* Status Dropdown */
.status-wrap { position: relative; width: 100%; }
.status-select { width: 100%; padding: 6px 4px; border: 1px solid #ccc; border-radius: 4px; font-size: 12px; background: #fff; cursor: pointer; box-sizing: border-box; text-overflow: ellipsis; text-align: center; }
.status-text { font-weight: bold; padding: 4px 8px; display: inline-block; }
.spinner { position: absolute; left: 5px; top: 8px; width: 14px; height: 14px; border: 2px solid #ccc; border-top-color: #0d6efd; border-radius: 50%; animation: spin 0.8s linear infinite; display: none; pointer-events: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Colors */
.st-completed td { background-color: #d1e7dd !important; }
.st-cancelled td { background-color: #f8d7da !important; }
.st-scheduled td { background-color: #fff3cd !important; }

/* Borders */
tr.row-start td { border-top: 2px solid #ced4da; }
tr.row-end td { border-bottom: 2px solid #ced4da; }
tr.row-start:not(.row-end) td { border-bottom: none; }

/* PDF Button */
.pdf-btn { display: inline-block; background: #0d6efd; color: #fff; padding: 4px 10px; border-radius: 4px; text-decoration: none; font-weight: 500; font-size: 12px; }
.pdf-btn:hover { background: #0b5ed7; color: #fff; }
.col-phone { font-family: monospace; font-size: 13px; direction: ltr; }

/* Mobile View */
@media (max-width: 900px) {
    .af-portal-wrapper { padding: 10px; }
    .af-portal-table { min-width: 0; }
    .af-portal-table, .af-portal-table tbody, .af-portal-table tr, .af-portal-table td { display: block; width: 100%; box-sizing: border-box; }
    .af-portal-table thead { display: none; }
    
    .af-portal-table tr { margin-bottom: 15px; border: 1px solid #ddd; background: #fff; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,0.05); }
    
    .af-portal-table td { 
        display: flex; 
        justify-content: space-between; 
        align-items: center; 
        text-align: left; /* Keep left alignment for values on mobile cards */
        padding: 10px 15px; 
        border-bottom: 1px solid #f0f0f0; 
        min-height: 45px; 
    }
    
    .af-portal-table td:last-child { border-bottom: none; }
    
    .af-portal-table td::before { 
        content: attr(data-label); 
        font-weight: 600; 
        text-align: right; 
        margin-left: 15px; 
        color: #666; 
        width: 35%; 
        flex-shrink: 0; 
        font-size: 12px; 
        text-transform: uppercase; 
    }
    
    /* Reset widths for mobile */
    .col-status, .col-name, .col-addr { width: auto; min-width: 0; }
    .status-wrap { width: 60%; max-width: 200px; }
    .col-phone, .col-id, .col-pdf { text-align: left; }
    
    tr.row-start:not(.row-end) { margin-bottom: 0; border-bottom: none; border-radius: 8px 8px 0 0; }
    tr.row-end:not(.row-start) { margin-top: 0; border-top: 1px dashed #ccc; border-radius: 0 0 8px 8px; }
}

@media (max-width: 480px) {
    .af-header { flex-direction: column; align-items: flex-start; }
    .header-meta { width: 100%; justify-content: space-between; margin-top: 10px; }
    .filter-item { flex: 1 1 100%; }
    
    .af-portal-table td { flex-direction: column; align-items: flex-start; gap: 5px; }
    .af-portal-table td::before { width: 100%; text-align: right; margin-left: 0; margin-bottom: 2px; }
    
    .status-wrap { width: 100%; max-width: none; }
    .col-phone { text-align: right; }
}