.affwp-table.affwp-table-responsive thead th {
    background: #e34f43;
    font-weight: 600;
    font-size: 16px;
    color: #fff;
}

.affwp-table.affwp-table-responsive tbody td {
    font-size: 15px;
}

.affwp-table.affwp-table-responsive tbody td:first-child {
    font-weight: 500;
}


/* Responsive Start */
@media (max-width: 767px) {

    .affwp-table-responsive th,
    .affwp-table-responsive td {
        display: table-cell;
        width: 180px;
        min-width: 180px;
    }

    .affwp-table-responsive td:before {
        display: none;
    }

    .affwp-table.affwp-table-responsive {
        overflow-x: scroll;
        display: block;
    }
}

/* Sub Affiliate Network Visualization */
.sub-aff-network-container {
    background-color: #f8f9fa;
    padding: 2rem;
    border-radius: 12px;
    margin-top: 20px;
    position: relative; /* REQUIRED for portal tooltip positioning */
}

/* Network Capacity Alerts */
.asaf-network-alert {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 18px 24px;
    border-radius: 12px;
    margin-bottom: 25px;
    font-size: 15px;
    line-height: 1.5;
    animation: asaf-fade-in 0.4s ease-out;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

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

.asaf-alert-success {
    background-color: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #166534;
}

.asaf-alert-success .asaf-alert-icon {
    color: #22c55e;
}

.asaf-alert-info {
    background-color: #f0f9ff;
    border: 1px solid #bae6fd;
    color: #075985;
}

.asaf-alert-info .asaf-alert-icon {
    color: #0ea5e9;
}

.asaf-alert-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.asaf-alert-icon .dashicons {
    font-size: 24px;
    width: 24px;
    height: 24px;
}

.asaf-alert-content {
    flex-grow: 1;
    font-weight: 600;
}

.sub-aff-network-header {
    margin-bottom: 3rem;
    border-bottom: 2px solid #e1e4e8;
    padding-bottom: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.network-zoom-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #fff;
    padding: 8px 15px;
    border-radius: 30px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    border: 1px solid #e2e8f0;
}

.zoom-btn {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
    color: #64748b;
}

.zoom-btn:hover {
    background: #eff6ff;
    border-color: #3b82f6;
    color: #3b82f6;
}

.zoom-btn .dashicons {
    font-size: 20px;
    width: 20px;
    height: 20px;
}

.zoom-level-indicator {
    font-size: 14px;
    font-weight: 600;
    color: #475569;
    min-width: 50px;
    text-align: center;
}

.network-viewport {
    width: 100%;
    height: 600px;
    background-color: #f1f5f9;
    background-image: radial-gradient(#cbd5e1 1px, transparent 1px);
    background-size: 40px 40px;
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    cursor: grab;
    border: 1px solid #e2e8f0;
}

.network-viewport:active {
    cursor: grabbing;
}

.sub-aff-network-visualization {
    display: block;
    width: max-content;
    min-width: 100%;
    padding: 300px 100px;
    transform-origin: 0 0;
    transition: transform 0.1s ease-out;
    will-change: transform;
}

.tree-root {
    display: flex;
    justify-content: center;
}

.node-branch {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    padding: 0 0.5rem;
}

.node-card {
    width: 180px;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    position: relative;
    z-index: 10;
    transition: transform 0.2s ease;
    border: 1px solid #e2e8f0;
    cursor: pointer;
}

.node-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    z-index: 100;
}

.node-tooltip {
    display: none !important; /* Data source only - hidden in nodes */
}

/* Style for the Portal Tooltip - This now floats ON THE BODY (Universal Visibility) */
.portal-tooltip-body {
    position: fixed !important;
    display: none;
    pointer-events: none;
    z-index: 9999999 !important;
    width: 240px;
    background: #fff;
    border-radius: 8px;
    padding: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    border: 1px solid #f1f5f9;
}

.portal-tooltip-body.is-visible {
    display: block !important;
    opacity: 1;
}

/* Tooltip Little Arrow */
.portal-tooltip-body::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -10px;
    border-width: 10px;
    border-style: solid;
    border-color: #fff transparent transparent transparent;
}

.tooltip-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.tooltip-row-stack {
    margin: 5px 0;
}

.tooltip-label {
    font-size: 13px;
    color: #4b5563;
    font-weight: 500;
}

.tooltip-value {
    font-size: 14px;
    color: #111827;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.tooltip-value .dashicons {
    font-size: 24px;
    width: 24px;
    height: 24px;
    color: #6b7280;
}

.tooltip-value-large {
    font-size: 18px;
    color: #111827;
    font-weight: 800;
}

.tooltip-divider {
    height: 1px;
    background-color: #f1f5f9;
    margin: 15px 0;
}

.tooltip-sub-info {
    font-size: 14px;
    color: #94a3b8;
    text-align: right;
    margin-bottom: 8px;
    font-weight: 500;
}

.tooltip-progress-bg {
    height: 8px;
    background-color: #f1f5f9;
    border-radius: 4px;
    overflow: hidden;
}

.tooltip-progress-bar {
    height: 100%;
    background-color: #64748b;
    border-radius: 4px;
    transition: width 0.8s ease;
}

.node-card-root {
    border: 2px solid #3b82f6;
}

.star-icon {
    position: absolute;
    top: 0px;
    left: 2px;
    color: #fbbf24;
    font-size: 1.2rem;
    z-index: 20;
}

.node-header {
    background-color: #1e293b;
    color: #fff;
    padding: 8px 10px;
    text-align: center;
    font-weight: 700;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.node-body {
    padding: 10px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.avatar-container {
    flex-shrink: 0;
    margin-top: -22px;
    z-index: 15;
    position: relative;
}

.avatar-img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid #fff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}

.stats-container {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
}

.node-stat {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: #1a1a1a;
    line-height: 1.2;
    font-weight: 400;
}

.stat-value {
    font-weight: 600;
    color: #1a1a1a;
    margin-left: 10px;
}

/* Tree Connectors Logic */
.tree-line-v {
    width: 2px;
    height: 25px;
    background-color: #cbd5e1;
    flex-shrink: 0;
    position: relative;
}

.node-children-wrapper {
    position: relative;
    width: 100%;
}

.node-children {
    display: flex;
    justify-content: center;
    position: relative;
    padding-top: 0;
}

/* Horizontal connectors using pseudo-elements on branches */
.node-branch::before,
.node-branch::after {
    content: "";
    position: absolute;
    top: 0;
    right: 50%;
    width: 50%;
    height: 2px;
    background-color: #cbd5e1;
    z-index: 1;
}

.node-branch::after {
    right: auto;
    left: 50%;
}

/* Remove horizontal line for single child or edges */
.node-branch:only-child::before,
.node-branch:only-child::after {
    display: none;
}

.node-branch:first-child::before {
    display: none;
}

.node-branch:last-child::after {
    display: none;
}

/* The vertical line leading UP to a child needs to SIT ON TOP of the horizontal line */
.node-branch>.tree-line-v {
    z-index: 2;
}

/* Root node doesn't need a top connector */
.node-branch.is-root::before,
.node-branch.is-root::after {
    display: none;
}

/* Ensure node-card centers itself and stays above lines */
.node-card {
    margin: 0 auto;
    z-index: 10;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .sub-aff-network-visualization {
        justify-content: flex-start;
    }
}

/* Recruitment Link Section */
.recruitment-link-section {
    background: #ffffff !important;
    border: 1px solid #f1f5f9 !important;
    border-radius: 16px !important;
    padding: 32px !important;
    margin: 20px 0 40px 0 !important;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03) !important;
}

.recruitment-link-header h3 {
    margin: 0 0 8px 0 !important;
    font-size: 1.25rem !important;
    color: #0f172a !important;
    font-weight: 700 !important;
    letter-spacing: -0.02em !important;
    font-family: inherit !important;
}

.recruitment-link-header p {
    margin: 0 0 24px 0 !important;
    color: #64748b !important;
    font-size: 0.95rem !important;
    line-height: 1.5 !important;
    font-family: inherit !important;
}

.recruitment-link-copy-wrapper {
    display: flex !important;
    gap: 0 !important;
    background: #f8fafc !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 12px !important;
    overflow: hidden !important;
    transition: all 0.2s ease !important;
    box-shadow: inset 0 2px 4px 0 rgba(0, 0, 0, 0.03) !important;
    height: 56px !important;
    align-items: stretch !important;
}

.recruitment-link-copy-wrapper:hover {
    border-color: #cbd5e1 !important;
}

.recruitment-link-copy-wrapper:focus-within {
    border-color: #5850ec !important;
    box-shadow: 0 0 0 3px rgba(88, 80, 236, 0.1), inset 0 2px 4px 0 rgba(0, 0, 0, 0.03) !important;
    background: #ffffff !important;
}

.recruitment-url-input {
    flex-grow: 1 !important;
    border: none !important;
    padding: 0 20px !important;
    background: transparent !important;
    color: #334155 !important;
    font-size: 1rem !important;
    height: 100% !important;
    width: 100% !important;
    outline: none !important;
    box-shadow: none !important;
    margin: 0 !important;
    font-family: monospace !important;
}

.recruitment-copy-btn {
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%) !important;
    color: #ffffff !important;
    border: none !important;
    border-radius: 0 !important;
    padding: 0 32px !important;
    font-weight: 600 !important;
    font-size: 1rem !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    height: 100% !important;
    white-space: nowrap !important;
    margin: 0 !important;
    box-shadow: none !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.recruitment-copy-btn:hover {
    background: linear-gradient(135deg, #4f46e5 0%, #4338ca 100%) !important;
    padding: 0 36px !important;
}

.recruitment-copy-btn:active {
    transform: scale(0.98) !important;
}

.recruitment-copy-btn.copied {
    background: #059669 !important;
}

@media (max-width: 640px) {
    .recruitment-link-section {
        padding: 24px !important;
    }

    .recruitment-link-copy-wrapper {
        flex-direction: column !important;
        border: none !important;
        background: transparent !important;
        gap: 12px !important;
        height: auto !important;
        box-shadow: none !important;
    }

    .recruitment-url-input {
        border: 1px solid #e2e8f0 !important;
        border-radius: 10px !important;
        background: #f8fafc !important;
        height: 48px !important;
    }

    .recruitment-copy-btn {
        border-radius: 10px !important;
        width: 100% !important;
        height: 48px !important;
    }
}

.node-pending {
    color: #718096;
    font-size: 0.875rem;
    font-style: italic;
    margin-top: 4px;
}

/* Deleted User Styles */
.node-card-deleted {
    border: 1px dashed #cbd5e1 !important;
    background-color: #f8fafc !important;
    opacity: 0.8;
}

.node-card-deleted:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05) !important;
    transform: none !important;
}

.node-card-deleted .node-footer, 
.node-card-deleted .star-icon {
    display: none !important;
}

.node-card-deleted .node-header {
    background-color: #64748b !important;
    color: #f1f5f9;
}

.node-card-deleted .avatar-placeholder {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 3px solid #fff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.node-card-deleted .avatar-placeholder .dashicons {
    font-size: 20px;
    width: 20px;
    height: 20px;
    color: #94a3b8;
}

.node-card-deleted .node-stat,
.node-card-deleted .stat-value {
    color: #94a3b8 !important;
}

/* Over Capacity Styles */
.node-branch.is-over-capacity > .node-card {
    border: 2px solid #ef4444 !important;
    background-color: #fef2f2 !important;
}

.over-capacity-badge {
    display: inline-block;
    background-color: #ef4444;
    color: #fff;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 8px;
    font-weight: 800;
    text-transform: uppercase;
    vertical-align: middle;
    animation: asaf-pulse-red 2s infinite;
    cursor: help;
}

@keyframes asaf-pulse-red {
    0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
    100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.node-branch.is-over-capacity > .node-card .node-header {
    background-color: #991b1b !important;
}